php - PDO Update not updating data -
i know answer has been written countless amounts of time after spending 4 hours on this, can't seem find whats wrong. pdo update not updating. working few days ago , maybe have changed doesn't work @ now.
try { $query_update = $db->db_connection->prepare('update ghl_users set user_last_reset_code = :user_password_reset_hash, user_last_reset_request = :user_password_reset_timestamp user_name = :user_name'); $query_update->bindvalue(':user_password_reset_hash', $user_password_reset_hash, pdo::param_str); $query_update->bindvalue(':user_password_reset_timestamp', $temporary_timestamp, pdo::param_str); $query_update->bindvalue(':user_name', $user_name, pdo::param_str); $query_update->execute(); }catch( pdoexception $exception ) { throw new mydatabaseexception( $exception->getmessage( ) , (int)$exception->getcode( ) ); }
all variables set (e.g. when echo shows me values)
echo $user_name. "<br />"; echo $temporary_timestamp. "<br />"; echo $user_password_reset_hash. "<br />";
values are:
johndoe 2015-06-04 09:28:29 8ctkas9f3ef35jdk2k5jaeffe115j3kkdc2ae
you need parameterise unsafe values , $user_password_reset_hash
, stop injection. can use sql now()
update
try
try { $query_update = $db->db_connection->prepare('update ghl_users set user_last_reset_code = :user_password_reset_hash, user_last_reset_request = now() user_name = :user_name'); $query_update->bindvalue(':user_password_reset_hash', $user_password_reset_hash, pdo::param_str); $query_update->bindvalue(':user_name', $user_name, pdo::param_str); if ($query_update->execute()) { // success echo "updated record"; } else { // failure } }catch( pdoexception $exception ) { throw new mydatabaseexception( $exception->getmessage( ) , (int)$exception->getcode( ) ); }
also ensure errmode_exception
set
Comments
Post a Comment