MySQL错误的类型无法保存输入

时间:2014-06-30 12:30:23

标签: mysql

嘿伙计我无法将此输入保存到我的数据库中!

输入:

ö89118622353440500515_

我知道这个问题与int / string的TYPE有关但我无法弄明白。

这是我的表单/ 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
?>

有人可以帮我在我的数据库中找到合适的TYPE吗?提前谢谢!

0 个答案:

没有答案