php - PDO Success message not firing -
trying find out why success or failure message not displayed
i following in class inside php file
public $errors = array(); public $messages = array();
...
public function yyyy(xxxx) $this->db_connection->setattribute( pdo::attr_errmode, pdo::errmode_warning ); $query_user_update = $this->db_connection->prepare('update users set user_email = :user_email, user_type = :user_type id = :id'); $query_user_update->bindvalue(':user_email', $user_email, pdo::param_str); $query_user_update->bindvalue(':user_type', $user_type, pdo::param_str); $query_user_update->bindvalue(':id', $_session['id'], pdo::param_int); $query_user_update->execute(); $count = $query_user_update->rowcount();
i used $count show me if row updated used debugging make sure have updated @ least 1 row. following:
if ($query_user_update) { // set true page not reload form $this->updateuser_successful = true; // display success message $this->messages[] = message_userrecord_changed_successfully; print("we have updated $count rows.\n"); } else { // display failure message $this->errors[] = message_userrecord_changed_failed; }
i have included file contains messages using require_once('en.php) in php page loads form.
when run , update record in form , submit, $count 1 message "we have updated 1 row" displayed on screen message assigned message_userrecord_changed_successfully not. check database , can see record indeed updated.
i have form works bit puzzled. appreciated.
you have not returned or echoed.
if ($query_user_update) { // set true page not reload form $this->updateuser_successful = true; // display success message $this->messages[] = message_userrecord_changed_successfully; print("we have updated $count rows.\n"); return $this->messages; } else { // display failure message $this->errors[] = message_userrecord_changed_failed; return $this->errors; }
you in page form is:
$returndata = $someclass->somefunction(params); for($i = 0; $i < count($returndata); $i++) { echo $returndata[$i]; }
the $returndata variable holds returned array, either errors or messages.
Comments
Post a Comment