卡在这个错误:不正确的整数值:'' 列'____' 在第 1 行 [英] Stuck at this error: Incorrect integer value: '' for column '____' at row 1
本文介绍了卡在这个错误:不正确的整数值:'' 列'____' 在第 1 行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我提交表单并使用此脚本在数据库中插入数据时,出现上述错误...有什么想法吗?
When I submit the form and use this script to insert the data in the db i get the error mentioned above...any ideas?
//Include connect file to make a connection to test_cars database
include("prototypeconnect.php");
$proCode = $_POST["code"];
$proDescr = $_POST["description"];
$proManu = $_POST["manufacturer"];
$proCPU = $_POST["cost_per_unit"];
$proWPU = $_POST["weight_per_unit"];
$proBarCode = $_POST["bar_code"];
$proIngredients = $_POST["ingredients_list"];
$proAllergens = $_POST["allergens_contains"];
$proMayAllergens = $_POST["allergens_may_contain"];
//Insert users data in database
$sql = "INSERT INTO prodb.simplex_list
code, description, manufacturer,
cost_per_unit, weight_per_unit, bar_code,
ingredients_list, allergens_contains,
allergens_may_contain)
VALUES
( '$proCode', '$proDescr' , '$proManu',
'$proCPU' , '$proWPU' , '$proBarCode',
'$proIngredients' , '$proAllergens',
'$proMayAllergens')";
//Run the insert query
if (!mysql_query($sql)) {
echo mysql_error();
}
?>
更新:我删除了 id 插入,因为它们是自动递增的,我从你的回答中了解到不需要编码 null 并且 mysql 会照顾 AI.谢谢各位!
UPDATE: I removed id inserts as they are auto-increment and i learned from your answers that a null does not need to be coded and mysql looks after AI. Thanks guys!
推荐答案
Query need to be like:-
Query need to be like:-
$sql = "INSERT INTO prodb.simplex_list
(code, description, manufacturer,
cost_per_unit, weight_per_unit,
bar_code, ingredients_list, allergens_contains,
allergens_may_contain)
VALUES ('$proCode', '$proDescr', '$proManu',
'$proCPU','$proWPU', '$proBarCode',
'$proIngredients', '$proAllergens',
'$proMayAllergens')";
注意:-请停止使用mysql_*
.使用 mysqli_*
或 PDO
.此外,这仅在 id
字段必须自动递增时才有效.
Note:- please stop using mysql_*
. Use mysqli_*
or PDO
. Also this will work only when id
field must be auto incremented.
这篇关于卡在这个错误:不正确的整数值:'' 列'____' 在第 1 行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文