當我嘗試執行,這是和得到以下錯誤:PHP - MYSQL嘗試存儲整數值
Error: Incorrect integer value: 'Age' for column 'age' at row 1
MYSQL - >我創建了一個數據庫ABC內部創建一個表名EE並在表中我創建了一個字段「年齡」,類型 - 「INT」,長度 - 10,默認 - NULL
可以幫助我爲什麼我得到這錯誤 - 錯誤的整數值:'年齡'列1'列'年齡'
<html>
<body>
<form action="test5.php" method="post">
Age: <input type="text" name="age" />
<input type="submit" />
</form>
</body>
</html>
test5.php(頁)
$Age= $_POST[ age ] ;
echo $age;
$con = mysql_connect("localhost","root","***");
if(!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("abc", $con);
$sql = "INSERT INTO ee (Age) VALUES ('Age')";
if(!mysql_query($sql, $con))
{
die('Error: ' . mysql_error());
}
echo "1 record added";
mysql_close($con)
無論問題如何,請嘗試應用一些輸入驗證,您的代碼可以SQL調用注入。 – 2011-03-03 15:00:30