Reputation: 203
Hope this isn't just a typo, but I'm at my wits end. This code format and syntax works for another project of mine, but I just can't get anything.
Note 1: the variables are all populated. I checked with an echo.
Note 2: I checked to make sure all of the field names are the actual field names in MySQL table. All are varchar of at least 30 (which I didn't go over).
Note 3: The message is this: Error 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 ''username', 'userpassword', 'personname', 'familyname') VALUES ('hwilson':,'hwil' at line 1
Any help appreciated.
try {
// THIS IS THE SECURE STUFF!
$sql = "INSERT INTO persons (username, userpassword, personname, familyname) VALUES (:username:,:userpassword,:personname,:familyname)";
$q = $pdo->prepare($sql);
$q->execute(array(':username'=>$username,
':userpassword'=>$userpassword,
':personname'=>$personname,
':familyname'=>$familyname));
}
catch(PDOException $e)
{
echo "Error " . $e->getMessage();
}
}
Upvotes: 0
Views: 111
Reputation: 364
There appears to be second colon after the username parameter place holder
Upvotes: 2