-2

我正在尝试将表单值插入数据库,但数据不会进入 mysql。我花了很多时间但无法解决它......这是我的代码:

$query = "insert into $tabl (userid, username, question,  board, class, subject, article, status, uniq_id,date,activation  ) values('$userid', '$username', '$question', '$board', '$class', '$subject', '$article', 'unread', '$uniq',CURDATE(), '0')";
$row = mysql_query($query);

if($row)
{
     header("location:ask-questions.php?msg=saved");
}
else
{
    header("location:ask-questions.php?msg=not been saved");
}
//////////   (1)End of the Code /////////////
?>

一切都很好,我echo $sql,也可以正常工作......任何帮助将不胜感激......

4

1 回答 1

2

date是中的保留字mysql`当用作列名时,在这种保留字周围使用反引号。

 $query = "insert into $tabl (userid, username, question,  
 board, class, subject, article, status, uniq_id, `date`,activation  ) 
 values('$userid', '$username', '$question', '$board', '$class', '$subject', '$article', 'unread', '$uniq',CURDATE(), '0')";

 $row = mysql_query($query) OR die(mysql_error());

也停止使用mysql_*函数,它们已被弃用。开始mysqliPDO

于 2013-06-17T09:56:42.503 回答