我在 mysql 数据库中插入数据时遇到问题。错误显示如下:“您的 SQL 语法有错误;请检查与您的 MySQL 服务器版本相对应的手册,以在第 1 行的 '1')' 附近使用正确的语法”
<?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";
?>
顺便说一句,我的表中有 2 列名为 id 和 roll 应该自动生成...在这种情况下,它是正确的 sql 吗????