参见英文答案 > Syntax error due to using a reserved word as a table or column name in MySQL 1个
我试图让MysqL为我的表单提交工作.我尝试插入表格时遇到问题.
当我将信息放入我的表单并单击提交时(在此示例中,信息在一个字段中为“Idea”,在另一个字段中为“Description”)我得到此响应:
“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 ‘desc) VALUES
(‘Idea’,’Description’)’ at line 1”
这是我目前的代码:
PHP
MysqL_connect("localhost","root","") or die(MysqL_error());
MysqL_select_db("date_ideas") or die(MysqL_error());
$title=$_POST['title'];
$title=MysqL_real_escape_string($title);
$desc=$_POST['desc'];
$desc=MysqL_real_escape_string($desc);
$submit="INSERT INTO ideas (title,desc) VALUES ('$title','$desc');";
MysqL_query($submit) or die(MysqL_error());
echo ("Idea submitted. Click
如果你调用所使用的变量的回声它会成功传递信息,所以这不是问题.
最佳答案