[英]Having trouble inserting into mysql database via php with php variables? Can anyone tell me what I'm doing wrong?
[英]MySQL+PHP: Can anyone tell me what is wrong with this code?
我在運行此腳本時遇到問題,但我不斷收到相同的錯誤消息。 有人可以指出我要去哪里了嗎? 謝謝。
錯誤消息:您的SQL語法有錯誤。 檢查與您的MySQL服務器版本相對應的手冊,以在第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";
您在值列表中缺少右括號。
" VALUES ('{$postman}', '{$id}', '{$comment}', '{$datenow}' ";
^
Close-parenthesis goes here
提示
$datenow = date("Y-m-d") . " " . date("H:i:s");
可以簡化為:
$datenow = date("Y-m-d H:i:s");
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.