我在將數據插入到mysql數據庫時遇到問題。 錯誤是表明這樣的: 「您的SQL語法錯誤;檢查對應於你的MySQL服務器版本使用附近的正確語法手冊‘1’)」第1" 行MYSQL插入數據
<?php
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$fathername = $_POST['fathername'];
$mothername = $_POST['Firstname'];
$fatherjob = $_POST['fatherjob'];
$motherjob = $_POST['motherjob'];
$phone = $_POST['phone'];
$mobile1 = $_POST['mobile1'];
$mobile2 = $_POST['mobile2'];
$address = $_POST['address'];
$id=1;
$roll=1;
$sex = $_POST['sex'];
$bloodgroup = $_POST['bloodgroup'];
$class = $_POST['class'];
$section = $_POST['section'];
$day = $_POST['day'];
$month = $_POST['month'];
$year = $_POST['year'];
$birthday=$day."-".$month."-".$year;
$hostname_localhost ="localhost";
$database_localhost ="school";
$username_localhost ="root";
$password_localhost ="";
$localhost = mysql_connect($hostname_localhost,$username_localhost,$password_localhost)
or
trigger_error(mysql_error(),E_USER_ERROR);
mysql_select_db($database_localhost, $localhost);
$sql = "INSERT INTO student_info VALUES ('".$id."',".$firstname."','".$lastname."','".$sex."','".$bloodgroup."','".$fathername."','".$mothername ."','".$fatherjob."','".$motherjob."','".$address."','".$birthday."','".$phone."','".$mobile1."','".$mobile2."','".$class."','".$section."','".$roll."')";
mysql_query($sql) or die(mysql_error());
echo "updated succesfully";
?>
順便說一句,我ahve 2列在我的表中命名ID和滾動應該自動生成...在這種情況下,它是正確的SQL?