MySQL简单的插入查询不起作用

时间:2015-10-14 07:11:37

标签: php mysql mysqli

$insert = "INSERT INTO info (`id`,`user`,`roll`,`mob`,`pic`) VALUES (NULL,'$user','$roll','$mob','$pic')";
if($res = $conn->query($insert)){
    echo "Record Added";
}

简单的插入查询无效。

2 个答案:

答案 0 :(得分:-2)

试试这个

[{"date":"2013-08-24","type":"flag","graph":"g1","backgroundColor":"#85CDE6","value":"417","description":"This is description of an event"},{"date":"2013-08-25","type":"text","graph":"g1","backgroundColor":"#85CDE6","value":"417","description":"This is description of an event"},{"date":"2013-08-26","type":"text","graph":"g1","backgroundColor":"#85CDE6","value":"531","description":"This is description of an event"},{"date":"2013-08-27","type":"flag","graph":"g1","backgroundColor":"#00CC00","value":"333","description":"This is description of an event"},{"date":"2013-08-28","type":"flag","graph":"g1","backgroundColor":"#85CDE6","value":"552","description":"This is description of an event"},{"date":"2013-08-29","type":"flag","graph":"g1","backgroundColor":"#85CDE6","value":"492","description":"This is description of an event"},{"date":"2013-08-30","type":"sign","graph":"g1","backgroundColor":"#85CDE6","value":"379","description":"This is description of an event"},{"date":"2013-08-31","type":"arrowDown","graph":"g1","backgroundColor":"#85CDE6","value":"767","description":"This is description of an event"},{"date":"2013-09-01","type":"flag","graph":"g1","backgroundColor":"#85CDE6","value":"169","description":"This is description of an event"},{"date":"2013-09-02","type":"text","graph":"g1","backgroundColor":"#FFFFFF","value":"314","description":"This is description of an event"},{"date":"2013-09-03","type":"flag","graph":"g1","backgroundColor":"#85CDE6","value":"437","description":"This is description of an event"}]

答案 1 :(得分:-2)

正如此处所指出的,id列可能会自动递增,因此在查询中省略它:

$insert = "INSERT INTO info (`user`,`roll`,`mob`,`pic`) VALUES ('$user','$roll','$mob','$pic')";

此外,需要更多的信息/代码,因为查询甚至可以使用传入NULL的自动增量列,因此问题出在其他地方。

相关问题