是這樣的,mysqli_insert_id(connect()),returns the ID generated by a query on a table with a column having the AUTO_INCREMENT attribute. If the last query wasn't an?INSERT?or?UPDATE?statement or if the modified table does not have a column with the?AUTO_INCREMENT?attribute, this function?will return zero.
2017-04-17
是這樣的,mysqli_insert_id(connect()),returns the ID generated by a query on a table with a column having the AUTO_INCREMENT attribute. If the last query wasn't an?INSERT?or?UPDATE?statement or if the modified table does not have a column with the?AUTO_INCREMENT?attribute, this function?will return zero.
?也就是說,如果最后一句sql不是插入或者是update,返回值為0,我的建議是把insert方法的最后兩行變成:
$result=mysqli_query(connect(),$sql);
return $result;
mysqli_query()函數如果是插入操作成功,那么返回值為true;
2017-03-01
我跟你的問題一毛一樣,我也是實際添加進去但是就是報錯,我把判斷去掉了反正都能添加進去我就不加那個if(insert)了