我收到'不正确的整数值:''列country_id'。有时我的下拉菜单隐藏在表单中。所以我不确定如何处理这种情况。这是我的代码。谢谢你的帮助。
$countryId = isset($_POST['country']) ? $_POST['country'] : 0;
$inserSQL = "INSERT INTO Table1(country_id) VALUES('" .$countryId. "')";
$Result1 = mysql_query($inserSQL ) or die(mysql_error());
Run Code Online (Sandbox Code Playgroud)
要添加'到$countryId值。由于需要整数,因此您不必使用它们。尝试这个:
$countryId = isset($_POST['country']) ? (int)$_POST['country'] : 0;
$inserSQL = "INSERT INTO Table1(country_id) VALUES($countryId)";
$Result1 = mysql_query($inserSQL ) or die(mysql_error());
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
17014 次 |
| 最近记录: |