不正确的整数值:''表示第1行的列'height'

时间:2018-03-18 02:24:46

标签: php mysql sql

出现此错误,我不知道为什么,这是我的代码:

// Create connection 
$conn = @mysqli_connect($server,$user,$pass,$dbname) or die('can not connect to php');

$sql_store = "INSERT into test (userName, userAgent, language,
javaEnabled, height) VALUES ('$userName', '$userAgent',
'$language', '$javaEnabled', '$height')";
$sql = mysqli_query($conn, $sql_store) or die(mysqli_error($conn));

这是我的高度javascript:

function height(){
var height = screen.height;
document.getElementById('height').innerHTML = height;
return height;
}

这是传递

xmlhttp.open("POST", example.com/ex.php", true);
xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");

xmlhttp.send("userName=" + checkCookie() +
             "&userAgent=" + userAgent() +
             "&language=" + language() +
             "&javaEnabled=" + javaEnabled() +
             "&height=" + height()); /*  fire and forget */
return true;

1 个答案:

答案 0 :(得分:1)

在将高度的值发送到数据库之前,您应检查$ height的值是否为有效整数。

在$ sql_store行之前,这样的东西应该有所帮助:

$height = round($height);