Mærkelig forum fejl.
Hej.Jeg får en mærkelig fejl når jeg prøver at poste en trod i mit forum.
Fejlen:
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.
Her er min kode:
<table width="400" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<form id="form1" name="form1" method="post" action="tilfoej.php">
<td>
<table width="100%" height="352" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
<tr>
<td colspan="3" bgcolor="#E6E6E6"><strong>Opret ny topic</strong> </td>
</tr>
<tr>
<td width="14%"><strong>Overskrift</strong></td>
<td width="2%">:</td>
<td width="84%"><input name="topic" type="text" id="topic" size="50" /></td>
</tr>
<tr>
<td valign="top"><strong>Tekst:</strong></td>
<td valign="top">:</td>
<td><textarea name="detail" cols="80" rows="10" id="detail"></textarea></td>
</tr>
<tr>
<td><strong>Navn</strong></td>
<td>:</td>
<td><input name="name" type="text" id="name" size="50" /></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td><input type="submit" name="Submit" value="Opret" /></td>
</tr>
</table>
</td>
</form>
</tr>
</table>
<?php
$query = mysql_query("SELECT `ip` FROM `banned` WHERE `ip` = '". $_SERVER["REMOTE_ADDR"] ."'");
if(mysql_num_rows($query) != 0) {
die("Du er banned");
}
?>
<font face="Tahoma">
<?php
$host="localhost";
$username="fozie_dk";
$password="";
$db_name="fozie_dk";
$tbl_name="forum_question";
// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
if($_POST){
$topic=$_POST['topic'];
$detail=$_POST['detail'];
$name=$_POST['navn'];
$datetime=date("d/m/y h:i:s");
if(empty($_POST['name']))die("Navn tak.");
if(empty($_POST['topic']))die("Overskrift tak.");
if(empty($_POST['detail']))die("Besked tak.");
if($_POST['name'] == 'Fozie')die("Du skal ikke hedde fozie, det er reserveret :\)");
else {
mysql_query("INSERT INTO $tbl_name(topic, detail, name, dateogtime)VALUES('$topic', '$detail', '$name', '$datetime')) OR DIE(mysql_error());
echo "Tilføjet";
}
}
?>