Trying to run this insert query
$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>';
I get this error:
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
This ($query->execute(array...)
being line 61
Your query is incorrect, that's why you are receiving syntax error. You missed ending )
.
INSERT INTO contacts (
id,
firstname,
lastname,
phonenumber,
rank,
time
) VALUES (
NULL,
:firstname,
:lastname,
:phone,
'1',
NOW()
)
It's easier to find such mistakes after formatting query.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.