MySQL Query不是Executing

时间:2013-07-29 15:28:45

标签: php mysql mysqli

我写了这个MySQLi查询:

$query = mysqli_query($con,"INSERT INTO listings (cat_id, comp, add, city, zip, state, phone, email, url, payopt, image_path, det1title, det2title, det3title, det1det, det2det, det3det) VALUES ('$cat_id','$comp','$add','$city','$zip','$state','$phone','$email','$url','$payOpt','$image_path','$det1title','$det2title','$det3title','$det1det','$det2det','$det3det')");

它显示错误查询为空。

1 个答案:

答案 0 :(得分:4)

按照惯例,绝对没有错误处理,所以你永远不会看到addreserved word,需要用反引号引用:

INSERT INTO listings (cat_id, comp, `add`, cit
                                    ^---^-- here

永远不要假设查询成功。始终检查失败的返回值,并在事情真正起作用时感到惊喜。