我已经制作了一个以前工作正常的注册表单,但是在我的代码进行了一些更改后,我有错误“错误:列数与第 1 行的值计数不匹配”
<?php
$host = "localhost";
$user = "root";
$db_name= "login_stock";
$pass= "usbw";
$con = mysql_connect($host, $user, $pass);
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("login_stock", $con);
$name=mysql_real_escape_string($_POST['name']); //This value has to be the same as in the HTML form file
$password=mysql_real_escape_string($_POST['password']); //This value has to be the same as in the HTML form file
$sql="INSERT INTO member_login (id,Name,Password, Allowance) VALUES (NULL,'$name','$password, 100000')";
if (!mysql_query($sql,$con)) {
die('Error: ' . mysql_error());
}
echo "The form data was successfully added to your database.";
mysql_close($con);
?>
数据库中的 id 是一个自动递增的 int 和一个主键。但是,用户在注册时不需要输入他们的 ID。
什么被认为是修复此错误的最佳方法!
提前致谢!