MySQL interesse |
|
Ik wil een figuur uploaden, nu heb ik het volgende script hiervoor:
<?
{
INCLUDE("../../style/config.inc.php");
INCLUDE("../../style/connect.php");
$naam = $_FILES['Foto']['name'];
$type = $_FILES['Foto']['type'];
$size = $_FILES['Foto']['size'];
COPY($_FILES['Foto']['tmp_name'], "../../upload/foto/".$naam);
$Foto = "../../upload/foto/".$naam;
$Datum = "$yyyy-$mm-$dd";
$sql="INSERT INTO foto(FotoID,Fotogroep,Titel,Foto,Datum,Omschrijving) VALUES('".$FotoID."','".$Fotogroep."','".$Titel."','".$Foto."','".$Datum."','".$Omschrijving."')";
$result = mysql_query($sql) or die(mysql_error());
ECHO"<META HTTP-EQUIV=\"refresh\" CONTENT=\"0; URL=foto.php\">";
}
?>
<? { INCLUDE("../../style/config.inc.php"); INCLUDE("../../style/connect.php"); $naam = $_FILES['Foto']['name']; $type = $_FILES['Foto']['type']; $size = $_FILES['Foto']['size']; COPY($_FILES['Foto']['tmp_name'], "../../upload/foto/".$naam); $Foto = "../../upload/foto/".$naam; $Datum = "$yyyy-$mm-$dd"; $sql="INSERT INTO foto(FotoID,Fotogroep,Titel,Foto,Datum,Omschrijving) VALUES('".$FotoID."','".$Fotogroep."','".$Titel."','".$Foto."','".$Datum."','".$Omschrijving."')"; ECHO"<META HTTP-EQUIV=\"refresh\" CONTENT=\"0; URL=foto.php\">"; } ?>
En het volgende om formulier om het in te voegen:
<TABLE WIDTH="400 PX" BORDER="0" BORDERPROPERTIES="0" CELLPADDING="0" CELLSPACING="1">
<FORM METHOD="POST" ACTION="fotoitem_toevoeging.php">
<TR>
<TD WIDTH="150 PX" HEIGHT="20 PX">
<FONT COLOR="#4F4F4F" SIZE="1" FACE="VERDANA">
<B>Fotogroep naam:</B>
</FONT>
</TD>
<TD WIDTH="250 PX" HEIGHT="20 PX">
<SELECT NAME="Fotogroep">
<?
$sql=mysql_query("SELECT * FROM fotogroep");
WHILE ($data = mysql_fetch_array($sql))
{
ECHO"
<OPTION VALUE=".$data['Fotogroep'].">".$data['Fotogroep']."</OPTION>
";
}
?>
</SELECT>
</TD>
</TR>
<TR>
<TD WIDTH="150 PX" HEIGHT="20 PX">
<FONT COLOR="#4F4F4F" SIZE="1" FACE="VERDANA">
<B>Titel:</B>
</FONT>
</TD>
<TD WIDTH="250 PX" HEIGHT="20 PX">
<INPUT TYPE="TEXT" NAME="Titel" SIZE="20">
</TD>
</TR>
<TR>
<TD WIDTH="150 PX" HEIGHT="20 PX">
<FONT COLOR="#4F4F4F" SIZE="1" FACE="VERDANA">
<B>Datum:</B>
</FONT>
</TD>
<TD WIDTH="250 PX" HEIGHT="20 PX">
<INPUT TYPE="text" NAME="dd" VALUE="00" SIZE="2">
<INPUT TYPE="text" NAME="mm" VALUE="00" SIZE="2">
<INPUT TYPE="text" NAME="yyyy" VALUE="0000" SIZE="4">
</TD>
</TR>
<TR>
<TD WIDTH="150 PX" HEIGHT="20 PX">
<FONT COLOR="#4F4F4F" SIZE="1" FACE="VERDANA">
<B>Foto:</B>
</FONT>
</TD>
<TD WIDTH="250 PX" HEIGHT="20 PX">
<INPUT TYPE="FILE" NAME="Foto" SIZE="20">
</TD>
</TR>
<TR>
<TD WIDTH="150 PX" HEIGHT="20 PX">
<FONT COLOR="#4F4F4F" SIZE="1" FACE="VERDANA">
<B>Omschrijving:</B>
</FONT>
</TD>
<TD WIDTH="250 PX" HEIGHT="20 PX">
<INPUT TYPE="TEXT" NAME="Omschrijving" SIZE="20">
</TD>
</TR>
<TR>
<TD WIDTH="400 PX" HEIGHT="20 PX" COLSPAN="2">
<INPUT TYPE="SUBMIT" VALUE=" Foto toevoegen " NAME="OK">
</TD>
</TR>
</FORM>
</TABLE>
<TABLE WIDTH="400 PX" BORDER="0" BORDERPROPERTIES="0" CELLPADDING="0" CELLSPACING="1"> <FORM METHOD="POST" ACTION="fotoitem_toevoeging.php"> <TR> <TD WIDTH="150 PX" HEIGHT="20 PX"> <FONT COLOR="#4F4F4F" SIZE="1" FACE="VERDANA"> <B>Fotogroep naam:</B> </FONT> </TD> <TD WIDTH="250 PX" HEIGHT="20 PX"> <SELECT NAME="Fotogroep"> <? { <OPTION VALUE=".$data['Fotogroep'].">".$data['Fotogroep']."</OPTION> "; } ?> </SELECT> </TD> </TR> <TR> <TD WIDTH="150 PX" HEIGHT="20 PX"> <FONT COLOR="#4F4F4F" SIZE="1" FACE="VERDANA"> <B>Titel:</B> </FONT> </TD> <TD WIDTH="250 PX" HEIGHT="20 PX"> <INPUT TYPE="TEXT" NAME="Titel" SIZE="20"> </TD> </TR> <TR> <TD WIDTH="150 PX" HEIGHT="20 PX"> <FONT COLOR="#4F4F4F" SIZE="1" FACE="VERDANA"> <B>Datum:</B> </FONT> </TD> <TD WIDTH="250 PX" HEIGHT="20 PX"> <INPUT TYPE="text" NAME="dd" VALUE="00" SIZE="2"> <INPUT TYPE="text" NAME="mm" VALUE="00" SIZE="2"> <INPUT TYPE="text" NAME="yyyy" VALUE="0000" SIZE="4"> </TD> </TR> <TR> <TD WIDTH="150 PX" HEIGHT="20 PX"> <FONT COLOR="#4F4F4F" SIZE="1" FACE="VERDANA"> <B>Foto:</B> </FONT> </TD> <TD WIDTH="250 PX" HEIGHT="20 PX"> <INPUT TYPE="FILE" NAME="Foto" SIZE="20"> </TD> </TR> <TR> <TD WIDTH="150 PX" HEIGHT="20 PX"> <FONT COLOR="#4F4F4F" SIZE="1" FACE="VERDANA"> <B>Omschrijving:</B> </FONT> </TD> <TD WIDTH="250 PX" HEIGHT="20 PX"> <INPUT TYPE="TEXT" NAME="Omschrijving" SIZE="20"> </TD> </TR> <TR> <TD WIDTH="400 PX" HEIGHT="20 PX" COLSPAN="2"> <INPUT TYPE="SUBMIT" VALUE=" Foto toevoegen " NAME="OK"> </TD> </TR> </FORM> </TABLE>
Maar dit werkt niet, wat doe ik fout
Bij deze ook nog even de sql-dump van de table Foto
CREATE TABLE `foto` ( `FotoID` int(11) NOT NULL AUTO_INCREMENT, `Fotogroep` varchar(50) DEFAULT NULL, `Titel` varchar(200) NOT NULL DEFAULT '', `Foto` varchar(200) NOT NULL DEFAULT '', `Datum` date NOT NULL DEFAULT '0000-00-00', `Omschrijving` varchar(200) NOT NULL DEFAULT '', UNIQUE KEY `FotoID` (`FotoID`)) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;
CREATE TABLE `foto` ( `FotoID` int(11) NOT NULL AUTO_INCREMENT, `Fotogroep` varchar(50) DEFAULT NULL, `Titel` varchar(200) NOT NULL DEFAULT '', `Foto` varchar(200) NOT NULL DEFAULT '', `Datum` date NOT NULL DEFAULT '0000-00-00', `Omschrijving` varchar(200) NOT NULL DEFAULT '', UNIQUE KEY `FotoID` (`FotoID`)) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;
|