Php 列计数不为';不匹配第1行的值计数
我有一个额外的列名为“id”,但它是一个具有自动递增功能的主键,如果我将其放入值中,它会添加id,但firstname数据始终为0,firstname数据输入lastname,lastname数据输入用户名,用户名数据输入email字段,email数据输入password字段,密码数据输入confirmpassword字段,最后输入confirmpassword数据国家/地区数据进入国家/地区字段。下面是我的代码 ?>Php 列计数不为';不匹配第1行的值计数,php,mysql,syntax-error,mysql-error-1064,Php,Mysql,Syntax Error,Mysql Error 1064,我有一个额外的列名为“id”,但它是一个具有自动递增功能的主键,如果我将其放入值中,它会添加id,但firstname数据始终为0,firstname数据输入lastname,lastname数据输入用户名,用户名数据输入email字段,email数据输入password字段,密码数据输入confirmpassword字段,最后输入confirmpassword数据国家/地区数据进入国家/地区字段。下面是我的代码 ?> <?php //connection to the databas
<?php
//connection to the database server
$hostname="localhost";
$user="root";
$password="";
$connection = mysql_connect($hostname, $user, $password) or die ("cannot connect to mysql database server");
//selection of database
mysql_select_db("jewelgallery", $connection) or die ("cannot reach jewelgallery database");
$firstname = $_POST['firstName'];
$lastname = $_POST['lastName'];
$username = $_POST['username'];
$email = $_POST['email'];
$password1 =$_POST['password'];
$password2 =$_POST['confirmPassword'];
$country =$_POST['country'];
$sql2="select * from customer_account where username = '$username'";
$results = mysql_query($sql2, $connection) or die(mysql_error());
$numOfRecords1 = mysql_num_rows($results);
$_SESSION["username"] = $username;
if ($numOfRecords1 != 0)
{
echo "<h3>This Username ". $_SESSION["username"]." Has been chosen by another user</h3> <a href=registercustomer.html> Please Try Again </a>";
header("Refresh:5;url=registercustomer.html");
exit;
}
$sql="insert into customer_account(firstname, lastname, username, email, password, confirmpassword, country)
Values('$firstname', '$lastname', '$username', '$email', '$password1', '$password2' '$country')";
mysql_query($sql, $connection) or die(mysql_error());
mysql_close($connection);
echo "Registration Successful. <a href=../index.html> Continue </a>";
header("Refresh:5;url=../index.html");
?>
您缺少一个逗号:
'$password2' '$country')";
^^^^^
HERE
更正:
$sql="insert into customer_account(firstname, lastname, username, email, password, confirmpassword, country)
Values('$firstname', '$lastname', '$username', '$email', '$password1', '$password2', '$country')";
您缺少一个逗号:
'$password2' '$country')";
^^^^^
HERE
更正:
$sql="insert into customer_account(firstname, lastname, username, email, password, confirmpassword, country)
Values('$firstname', '$lastname', '$username', '$email', '$password1', '$password2', '$country')";
您缺少一个逗号:
'$password2' '$country')";
^^^^^
HERE
更正:
$sql="insert into customer_account(firstname, lastname, username, email, password, confirmpassword, country)
Values('$firstname', '$lastname', '$username', '$email', '$password1', '$password2', '$country')";
您缺少一个逗号:
'$password2' '$country')";
^^^^^
HERE
更正:
$sql="insert into customer_account(firstname, lastname, username, email, password, confirmpassword, country)
Values('$firstname', '$lastname', '$username', '$email', '$password1', '$password2', '$country')";
很可能这些输入变量中的任何一个单引号都会导致VALUES()
列表显示为比实际列多。这是另一个非常重要的原因——针对注入转义这些变量也会转义引号,以避免破坏SQL。要查看执行前查询的外观,请选中echo$sql至少,如果您使用类似于$country=mysql\u real\u escape\u string($country)的模式,则代码>
在所有这些变量上,您将获得一些注入保护,查询可能会成功(请发布echo$sql;
的输出…),但也请参见,因为新代码不应使用不推荐的mysql_*()
extension。很可能这些输入变量中的任何一个单引号都会导致VALUES()
列表显示为比实际列多。这是另一个非常重要的原因——针对注入转义这些变量也会转义引号,以避免破坏SQL。要查看执行前查询的外观,请选中echo$sql至少,如果您使用类似于$country=mysql\u real\u escape\u string($country)的模式,则代码>
在所有这些变量上,您将获得一些注入保护,查询可能会成功(请发布echo$sql;
的输出…),但也请参见,因为新代码不应使用不推荐的mysql_*()
extension。很可能这些输入变量中的任何一个单引号都会导致VALUES()
列表显示为比实际列多。这是另一个非常重要的原因——针对注入转义这些变量也会转义引号,以避免破坏SQL。要查看执行前查询的外观,请选中echo$sql至少,如果您使用类似于$country=mysql\u real\u escape\u string($country)的模式,则代码>
在所有这些变量上,您将获得一些注入保护,查询可能会成功(请发布echo$sql;
的输出…),但也请参见,因为新代码不应使用不推荐的mysql_*()
extension。很可能这些输入变量中的任何一个单引号都会导致VALUES()
列表显示为比实际列多。这是另一个非常重要的原因——针对注入转义这些变量也会转义引号,以避免破坏SQL。要查看执行前查询的外观,请选中echo$sql至少,如果您使用类似于$country=mysql\u real\u escape\u string($country)的模式,则代码>
在所有这些变量上,您将获得一些注入保护,查询可能会成功(请发布echo$sql;
的输出…),但也请参见,因为新代码不应使用不推荐的mysql_*()
扩展编写。