I have a pretty simple UPDATE query which works when I execute it in PHPMyAdmin (so it's not an SQL syntax error). However, when I try to execute the query with PHP PDO, no error is displayed and not a single row is affected by the query.
I have error reporting set like this: PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
. But no error is shown. My PHP code looks like this:
try {
$sql = "UPDATE user
SET username = :username,
activation_token = :activation_token,
activation_date_time = :activation_date_time,
activation_status = :activation_status
WHERE activation_token = :current_activation_token";
$stmt = $dbh->get_instance()->prepare($sql);
$stmt->bindParam(':username', $username, PDO::PARAM_STR);
$stmt->bindParam(':activation_token', $empty_activation_token, PDO::PARAM_STR);
$stmt->bindParam(':activation_date_time', $datetime, PDO::PARAM_STR);
$stmt->bindParam(':activation_status', $active_status, PDO::PARAM_STR);
$stmt->bindParam(':current_activation_token', $activation_token, PDO::PARAM_STR);
$stmt->execute();
echo 'username: ' . $username;
}
catch(PDOException $e) {
echo $e;
}
I've also checked if I was somehow using reserved keywords or anything like that, but I'm pretty sure that's not the case. Why is this not working?