简体   繁体   English

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

[英]Incorrect integer value: '' for column 'height' at row 1

This error appear and i do not know why, here is my code: 出现此错误,我不知道为什么,这是我的代码:

// 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));

and this is my javascript for the height: 这是我的JavaScript的高度:

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

and here is the passing 这是过去

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;

You should check if the value of $height is a valid integer before sending it to the database. 在将其发送到数据库之前,应检查$ height的值是否为有效整数。

Something like this, before the $sql_store line, should help: 像这样,在$ sql_store行之前,应该有所帮助:

$height = round($height);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM