gpt4 book ai didi

php - 一个我没有得到的错误,MYSQL PDO PHP

转载 作者:太空宇宙 更新时间:2023-11-03 12:22:14 26 4
gpt4 key购买 nike

尝试运行这个插入查询

$query = $pdo->prepare("INSERT INTO `contacts` (`id`, `firstname`, `lastname`, `phonenumber`, `rank`, `time`) VALUES (NULL, :firstname, :lastname, :authcode, '1', NOW()");
$query->execute(array(":firstname" => $firstname, ":lastname" => $lastname, ":phone" => $phone));
$message[1] = '<font color=lime>Successfully added!</font>';

我收到这个错误:

Warning: PDOStatement::execute() [pdostatement.execute]: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 in /public_html/contacts/add.php on line 61

这个 ($query->execute(array...) 是第 61 行

最佳答案

您的查询不正确,这就是您收到语法错误的原因。您错过了结尾 )

INSERT INTO contacts (
id,
firstname,
lastname,
phonenumber,
rank,
time
) VALUES (
NULL,
:firstname,
:lastname,
:phone,
'1',
NOW()
)

格式化查询后更容易发现此类错误。

关于php - 一个我没有得到的错误,MYSQL PDO PHP,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19350726/

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