0

I'm doing a PDO insert using the following code. The $con connection is working fine. This insert, however, fails with no useful error message.

Table Structure

`user_id` int(11) NOT NULL,
`email_address` varchar(100) NOT NULL,
`salt` varchar(6) NOT NULL,
`password` varchar(300) NOT NULL,
`verified` varchar(1) NOT NULL DEFAULT 'N',
`date_registered` datetime NOT NULL,
`last_login` datetime DEFAULT NULL

(user_id is an auto-increment/primary key)

Insert code

$stmt = $con->prepare("INSERT INTO 'users' ('email_address','salt','password','verified','date_registered') VALUES (:email, :salt, :pwdHash, 'N', SYSDATE())");
$stmt->bindParam(':email',$email, PDO::PARAM_STR);
$stmt->bindParam(':salt',$salt, PDO::PARAM_STR);
$stmt->bindParam(':pwdHash',$pwdHash, PDO::PARAM_STR);
$result = $stmt->execute();
if(!$result) {
    echo "ERROR CREATING USER ACCOUNT: ";
    print_r($con->errorInfo());
} else {
    echo "success";
}

This returns the following error:

ERROR CREATING USER ACCOUNT: Array ( [0] => 00000 [1] => [2] => )

Which contains no useful information. Any advice on troubleshooting this? The db account has insert privileges. I've done this a dozen times on other projects without issues (using the same basic code).

Anonymous Man
  • 2,776
  • 5
  • 19
  • 38
  • http://stackoverflow.com/questions/3999850/pdo-error-message – Mike B Feb 06 '17 at 21:11
  • 2
    Your quoting is incorrect. http://stackoverflow.com/questions/11321491/when-to-use-single-quotes-double-quotes-and-backticks-in-mysql Table & column names should be unquoted or backtick-quoted, not single quoted as string literals. (but enable PDO exceptions as suggested in the other linked answer) – Michael Berkowski Feb 06 '17 at 21:12
  • That was it. Rusty I guess. Thanks ans sorry for the dupe. – Anonymous Man Feb 06 '17 at 21:29

0 Answers0