This is my code:
<?php
mysql_connect("localhost", "[I]username[/I]", "[I]pw[/I]") or die("Fout:<br>\n".mysql_error());
mysql_select_db("[I]db_name[/I]") or die("Fout:<br>\n".mysql_error());
if(!$_POST){
?>
<form name="formulier" action="gastenboek.php" method="post" target="_self">
<table>
<tr>
<td>Naam:</td>
<td><input type="text" maxlength="25" name="name"></td>
</tr>
<tr>
<td>E-mail:</td>
<td><input type="text" maxlength="30" name="email"></td>
</tr>
<tr>
<td>Bericht:</td>
<td><textarea name="bericht" cols="50" rows="5"></textarea></td>
</tr>
</table>
<input type="submit" value="Verzend"><input type="reset" value="Reset">
</form>
<br>
<?php
}else{
$name=$_POST['name'];
$email=$_POST['email'];
$bericht=$_POST['bericht'];
[B]$opdracht="INSERT INTO gastenboek(name, email, time, bericht) VALUES('".$name."', '".$email."', NOW(), '".$bericht."'";
mysql_query($opdracht) or die("regel 56:<br>\n".mysql_error());[/B]
echo("Bedankt voor uw bijdrage aan het gastenboek.<br>");
}
echo("<table border=\"1\" bordercolor=\"#999999\">\n");
$result=mysql_query("SELECT * FROM gastenboek ORDER BY id DESC") or die("regel 60:<br>\n".mysql_error());
while($row=mysql_fetch_array($result)) {
echo("<tr>\n<td align=\"left\">");
echo("<a href=\"mailto: ".$row['email']."\">".$row['name']."</a></td>\n");
echo("<td align=\"right\">".$row['time']."</td>\n</tr>");
echo("<tr>\n<td colspan=\"2\">\n");
echo($row['bericht']);
echo("</td>\n</tr>\n<tr>\n<td height=\"10\"></td>\n</tr>");
}
echo("</table>")
?>
There is an error in line 56( the bold line). This is what is says:
You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
Does anybody know what is going wrong?
BTW this is for the guestbook I posted a thread about a few days ago, that was for asking how to put time in it. Thanks Cgraz and devinemike