tags:

views:

41

answers:

1

I am having problems running this script, but i keep on getting the same error message. Could someone point out where I am going wrong? Thanks.

Error message: 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

 $datenow = date("Y-m-d") . " " . date("H:i:s");
 $conn = mysql_connect('localhost', 'admin', 'root') or die(mysql_error());
mysql_select_db('main') or die(mysql_error());

 $queryh =  "INSERT INTO user_comments (posted_by, posted_to, comment, date_posted) ".
  " VALUES ('{$postman}', '{$id}', '{$comment}', '{$datenow}' ";

 $result = mysql_query($queryh) or die(mysql_error());

 echo "posted";
+3  A: 

You are missing the close-parenthesis on your values list.

" VALUES ('{$postman}', '{$id}', '{$comment}', '{$datenow}' ";
                                                           ^
                                             Close-parenthesis goes here

As a tip,

$datenow = date("Y-m-d") . " " . date("H:i:s");

can be shortened to be:

$datenow = date("Y-m-d H:i:s");
James McNellis
my god, what a stupid mistake... I just couldn't spot it. Thanks :)And sorry for spamming stackoverflow with such a stupid question.
Stephen
Meh, we've all done this and we'll all continue with it.
Jonas