Abbeh Posted March 7, 2007 Share Posted March 7, 2007 I'm attempting to install home-coded message boards on a website, and they're working fine - apart from when you try to post. Then I get this error message: Cannot create topic! 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 I'm still new to PHP, so I'd appreciate a few tips on why this is happening? If the code is needed then I can provide. Quote Link to comment Share on other sites More sharing options...
BrandonE97 Posted March 7, 2007 Share Posted March 7, 2007 Can we see the code? Quote Link to comment Share on other sites More sharing options...
Abbeh Posted March 7, 2007 Author Share Posted March 7, 2007 The first few lines are includes, and then the header code for the layout, they're working fine. This is the start of message board posting and replies. EDITED: This should be all, I think. <?php if($msg_id){ if(@$_POST['post_reply']){ $subject = strip_tags(@$_POST['subject']); $body = nl2br(@$_POST['body']); $date = date(YmdHis); if(!$subject){echo "<tr><td colspan=2><center><font color=red>Invalid Subject!</td></tr>";} if(!$body){echo "<tr><td colspan=2><center><font color=red>You must include a message.</td></tr>";exit;} @mysql_query("INSERT INTO msg_replies(board_id, subject, body, recent_reply, mid, reply_id) VALUES($board_id, '$subject', '$body', '$date', $mid, $msg_id)")or die("Cannot create topic! " . @mysql_error()); @mysql_query("UPDATE msg_replies SET recent_reply='$date' WHERE msg_id=$msg_id LIMIT 1")or die("Cannot update topic! " . @mysql_error()); echo "<tr><td colspan=2><center><font color=red>Message posted!</center></font></td></tr>"; $body = ""; } echo "$page_options</td></tr> <tr><Td colspan=2><b>Post Reply</b></td></tr> <tr><td>To post a reply to this topic, please fill out the following form. HTML <i>is</i> allowed. <form action='boards.php?id=$board_id&msg=".@$_GET['msg']."' method=post> <b>Subject:<br> <input type=text name='subject' maxlength=75 value='$subject'><br> Body:<br> <textarea name='body' rows=10 cols=50></textarea><br><br> <input type=submit name='post_reply' value='Post it!'></form> "; // if a messageboard, but no topic, has been selected, display all topics }elseif($board_id){ if(@$_POST['post_topic']){ $subject = strip_tags(@$_POST['subject']); $body = @$_POST['body']; $date = date(YmdHis); if(!$subject){echo "<center><font color=red>Invalid Subject!";exit;} if(!$body){echo "<center><font color=red>You must include a message.";exit;} @mysql_query("INSERT INTO msg_replies(board_id, subject, body, date, recent_reply, mid) VALUES($board_id, '$subject', '$body', '$date', '$date', $mid)")or die("Cannot create topic! " . @mysql_error()); echo "<center><font color=red>Topic posted!</center></font>"; } echo " $page_options</td></tr> <tr><Td colspan=2><h1 width=500> <br><b>Post Topic</b></td></tr> <tr><td>To post a new topic, please fill out the following form. HTML <i>is</i> allowed. <form action='boards.php?id=$board_id' method=post> <b>Subject:<br> <input type=text name='subject' maxlength=75><br> Body:<br> <textarea name='body' rows=10 cols=50></textarea><br><br> <input type=submit name='post_topic' value='Post it!'></form> "; ?> Quote Link to comment Share on other sites More sharing options...
trq Posted March 7, 2007 Share Posted March 7, 2007 You need to narrow the code down to the relevent parts. if you don't know which parts are relevent then you are more then likely looking for a developer rather then simple help. Quote Link to comment Share on other sites More sharing options...
Abbeh Posted March 7, 2007 Author Share Posted March 7, 2007 Okay, I cut it down to the "Post Topic" and "Post Reply" parts which are where the problems are. Quote Link to comment Share on other sites More sharing options...
Abbeh Posted March 7, 2007 Author Share Posted March 7, 2007 Any ideas? :-\ Quote Link to comment Share on other sites More sharing options...
bwochinski Posted March 7, 2007 Share Posted March 7, 2007 in the query under 'post_topic' where is $mid filled from? Quote Link to comment Share on other sites More sharing options...
trq Posted March 7, 2007 Share Posted March 7, 2007 Try... @mysql_query("INSERT INTO msg_replies (board_id, subject, body, recent_reply, mid, reply_id) VALUES ($board_id, '$subject', '$body', '$date', '$mid', '$msg_id')") or die("Cannot create topic! " . @mysql_error()); Notice the extra spaces. Quote Link to comment Share on other sites More sharing options...
Abbeh Posted March 7, 2007 Author Share Posted March 7, 2007 in the query under 'post_topic' where is $mid filled from? $mid = $_SESSION['mid']; Try... @mysql_query("INSERT INTO msg_replies (board_id, subject, body, recent_reply, mid, reply_id) VALUES ($board_id, '$subject', '$body', '$date', '$mid', '$msg_id')") or die("Cannot create topic! " . @mysql_error()); Notice the extra spaces. Thanks, I'll try it! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.