开发者

MySQL+PHP: Can anyone tell me what is wrong with this code?

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 a开发者_StackOverflow中文版n 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";


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");
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜