0

I have the following code:

// write new users data into database
$query_new_user_insert = $this->db_connection->prepare('INSERT INTO users (user_name, user_password_hash, user_email, user_activation_hash, user_registration_ip, user_registration_datetime) VALUES(:user_name, :user_password_hash, :user_email, :user_activation_hash, :user_registration_ip, now())');
$query_new_user_insert->bindValue(':user_name', $user_name, PDO::PARAM_STR);
$query_new_user_insert->bindValue(':user_password_hash', $user_password_hash, PDO::PARAM_STR);
$query_new_user_insert->bindValue(':user_email', $user_email, PDO::PARAM_STR);
$query_new_user_insert->bindValue(':user_activation_hash', $user_activation_hash, PDO::PARAM_STR);
$query_new_user_insert->bindValue(':user_registration_ip', $_SERVER["HTTP_CF_CONNECTING_IP"], PDO::PARAM_STR);
$query_new_user_insert->execute();
error_log( "Hello, errors!");
error_log($query_new_user_insert->error);
// id of new user
$user_id = $this->db_connection->lastInsertId();

if ($query_new_user_insert) {
     $this->messages[] = MESSAGE_REGISTRATION_ACTIVATION_SUCCESSFUL;
     $this->registration_successful = true;
} else {
     $this->errors[] = MESSAGE_REGISTRATION_FAILED;
}

No error is reported but no new row is added into mysql PHP reporting is on and error_log only shows (Hello, errors!)

Edit: Duplicate post answered question. A bind value was null

  • Can you show us how you created your connection? Are you certain that the connection is active? – Tim Biegeleisen May 18 '16 at 06:34
  • Mixing mysqli with PDO – Saty May 18 '16 at 06:34
  • Right above it there is this `else if ($this->databaseConnection()) { // check if username or email already exists $query_check_user_name = $this->db_connection->prepare('SELECT user_name, user_email FROM users WHERE user_name=:user_name OR user_email=:user_email'); $query_check_user_name->bindValue(':user_name', $user_name, PDO::PARAM_STR); $query_check_user_name->bindValue(':user_email', $user_email, PDO::PARAM_STR); $query_check_user_name->execute(); $result = $query_check_user_name->fetchAll();` And that execute – Emery Coughtry May 18 '16 at 06:46

0 Answers0