gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-29 13:19:04 25 4
gpt4 key购买 nike

当我尝试使用 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));

如有任何帮助,我们将不胜感激!

最佳答案

这里:

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

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

关于mysql - 使用 PDO 将行插入 MYSQL 表不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21095359/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com