MySQL错误类型无法保存输入
嘿,伙计们,我不能把这个输入保存到我的数据库中 输入:MySQL错误类型无法保存输入,mysql,Mysql,嘿,伙计们,我不能把这个输入保存到我的数据库中 输入: ö89118622353440500515_ 我知道这个问题与int/string的类型有关,但我无法理解 这是我的表单/script/phpscript <form id="checkout" name="checkout" method="post" action="checkout.php"> <input type="button" onclick="checkOut()" value="Låna
ö89118622353440500515_
我知道这个问题与int/string的类型有关,但我无法理解
这是我的表单/script/phpscript
<form id="checkout" name="checkout" method="post" action="checkout.php">
<input type="button" onclick="checkOut()" value="Låna Instrument"></button>
</form>
<script>
function checkOut(){
var userID=parseInt(prompt ("Dra ditt anställningskort"), 10);
var itemID=parseInt(prompt ("Skanna Instrument-ID"), 10);
var vari=(prompt ("Validering/Verifiering? Ja eller nej?"));
while(vari!="Ja" && vari!="Nej" && vari!="ja" && vari!="nej"){
alert ('Du måste skriva ja eller nej!');
var vari=(prompt ("Validering/Verifiering, Ja eller Nej?"));
}
if(userID!=null && itemID!=null && vari!=null){
window.location.href= "http://localhost/webapp/checkout.php?userID=" + userID + "&itemID=" + itemID + "&vari=" + vari;
alert ("Skickar Information!");
}
else{
alert ('error'. mysql_error);
}
}
</script>
<?php
$con = mysql_connect("localhost", "root", "") OR die(' Could not connect');
$db = mysql_select_db('book1', $con);
//connects to DB
if (isset($_GET["userID"]) && isset($_GET["itemID"]) && isset($_GET["vari"])){
$userID= (int)$_GET["userID"];
$itemID= (int)$_GET["itemID"];
$vari= $_GET["vari"];
$test = "userID: '$userID' itemID: '$itemID' vari: '$vari'";
echo $test;
echo "<br>";
}
//get ID's from browser
if (!$con) {
die('Could not connect: '.mysql_error());
}
//simple error msg
$upd = "UPDATE booking SET userID ='$userID', Verification='$vari', status='Unavailable' WHERE itemID ='$itemID'";
$retval = mysql_query($upd, $con);
//UPDATE the databas SET userID=userID and status=Unavailable if itemID=$itemID
if( !$retval || 0 === mysql_affected_rows ()){
echo('Error could not update data reason: invalid itemID. <br>'.mysql_error());
echo "<a href='http://localhost/webapp/index.php'>Go back </a>";
$fail = "failure";
}
//IF row's doesn't match send this error to index.php
else{
echo "Check out of instrument was successful!";
$success = "success";
}
//IF row's match send successful message
?>
有人能帮我在数据库中找到正确的类型吗?提前谢谢 您可以使用VARCHAR50它仍然不起作用。您的insert查询是什么?您的表是什么样子的?我刚刚更新了代码,请现在检查:我想是我自己找到的,是parseInt吗?