PHP PDO: UPDATE request not working and no errors

I have a fairly simple UPDATE query that works when I execute it in PHPMyAdmin (so this is not a SQL syntax error). However, when I try to execute a query with PHP PDO, no error is displayed and the query does not affect one line.

I have an error report, like this: PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION

. But no error is displayed. 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 also checked to see if I was somehow using reserved keywords or something, but I'm pretty sure that's not the case. Why doesn't it work?

+3


source to share





All Articles