0

我写了这个 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')");

它显示错误查询为空。

4

1 回答 1

4

像往常一样,绝对没有错误处理,所以你永远不会看到这add是一个保留字,需要用反引号引用:

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

永远不要假设查询是成功的。始终检查失败的返回值,并在实际工作时感到惊喜。

于 2013-07-29T15:34:37.370 回答