BazzyTK BazzyTK - 8 months ago 33
PHP Question

Why doesn't my query execute?

I have a query that get's fed these variables (but from a POST form):

$username = "John";
$email = "";
$passwordEnc = "9d4e1e23bd5b727046a9e3b4b7db57bd8d6ee684";
$activated = 0;
$activationKey = "5753a498f025464d72e088a9d5d6e872592d5f91";

The query is as follows:

$stmt = $dbu->prepare("INSERT INTO users (username, email, password, activated, key) VALUES (?, ?, ?, ?, ?)");
$stmt->execute(array($username, $email, $passwordEnc, $activated, $activationKey));

There is no error, but the entry isn't added to my table named 'users'.


You need to escape reserved words in MySQL like password and key with backticks

INSERT INTO users (username, email, `password`, activated, `key`) VALUES ...