“列计数与第1行的值计数不匹配".

“列计数与第1行的值计数不匹配

问题描述:

可能重复:
Mysql& PHP错误:列数与第1行的值数不符

Possible Duplicate:
Mysql & PHP Error: Column count doesn't match value count at row 1

我正在尝试用PHP创建一个帐户注册表格.我已经将其连接到我的MySQL数据库,但是在尝试使用表单进行注册后,出现标题中的错误.

I am trying to create an account registration form in PHP. I have connected it to my MySQL database, but after I try to sign up with the form I get the error that is in the title.

if(isset ($_POST['submit']))
{
    include( 'connection.php' );

    $username = $_POST['username'];
    $password = $_POST['password'];
    $email = $_POST['email'];

    if(empty($username) || empty($email) || empty($password))
    {
        echo 'Please check the required fields.';
    }
    elseif(!filter_var($email,FILTER_VALIDATE_EMAIL))
    {
        echo 'Please enter a correct email address.';
    }
    else
    {
        $password = md5($password);
        $sql = mysql_query("INSERT INTO users (email,username,password) VALUES ('$email','$username','$password',now())") or die(mysql_error());

        if($sql)
        {
            echo 'Successfully submitted.';
        }
    }   
}

3列:

$sql = mysql_query("INSERT INTO users (email,username,password)

4个值:

  VALUES ('$email','$username','$password',now())") ...