使用PDO将行插入MYSQL表不起作用

时间:2014-01-13 15:44:03

标签: mysql pdo insert row

当我尝试使用PDO将行插入MYSQL表时,它似乎不起作用。我没有收到任何错误消息,但是没有添加该行。这是我的代码:

$hostname = "localhost";
$database = "website";
$username = "leon";
$password = "*censored*";
$connect = new PDO("mysql:host=$hostname; dbname=$database; charset=utf8", $username, $password) or die("Can't connect!");
$sql = "INSERT INTO members(email, password, gender, firstname, middlename, lastname, zipcode, address, residence, telephone, activation)VALUES(:email, :encryptedpassword, :gender, :firstname, :middlename, :lastname, :zipcode, :address, :residence. :telephone, :activation)";
$register_user=$connect->prepare($sql);
$register_user->execute(array(':email'=>$email,
                  ':encryptedpassword'=>$encryptedpassword,
                  ':gender'=>$gender,
                  ':firstname'=>$firstname,
                  ':middlename'=>$middlename,
                  ':lastname'=>$lastname,
                  ':zipcode'=>$zipcode,
                  ':address'=>$address,
                  ':residence'=>$residence,
                  ':telephone'=>$telephone,                   
                  ':activation'=>$activation));

任何帮助将不胜感激!

1 个答案:

答案 0 :(得分:1)

下面:

VALUES(:email, :encryptedpassword, :gender, :firstname, :middlename, :lastname, :zipcode, :address, :residence. :telephone, :activation)";

:residence.后面有一个点,而不是逗号:residence,