整数值不正确:“"表示列错误 [英] Incorrect integer value: '' for column error
本文介绍了整数值不正确:“"表示列错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我得到的是"country_id列的整数值不正确".有时我的下拉菜单隐藏在表单中.因此,我不确定如何处理这种情况.这是我的代码.感谢您的帮助.
I am getting 'Incorrect integer value: '' for column country_id'. Sometimes my dropdown is hidden in the form. So I am not sure how to handle this situtation. Here is my code. Thanks for any help.
$countryId = isset($_POST['country']) ? $_POST['country'] : 0;
$inserSQL = "INSERT INTO Table1(country_id) VALUES('" .$countryId. "')";
$Result1 = mysql_query($inserSQL ) or die(mysql_error());
推荐答案
您正在将'
添加到$countryId
值.由于期望使用整数,因此您不必使用它们.试试这个:
You are adding '
to the $countryId
value. Since an integer is expected, you don't have to use them. Try this:
$countryId = isset($_POST['country']) ? (int)$_POST['country'] : 0;
$inserSQL = "INSERT INTO Table1(country_id) VALUES($countryId)";
$Result1 = mysql_query($inserSQL ) or die(mysql_error());
这篇关于整数值不正确:“"表示列错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文