I have the following PHP script that should be executed when the register button is clicked and if the address checkbox is checked.
if(isset($_POST['register'])){
   if($_POST['addressCheckBox']  == 'Yes'){
      if(isset($_POST['streetNumber']) && isset($_POST['route']) && isset($_POST['sublocality_level_1'])){
         $unitDetails = trim($_POST['unitDetails']);
         $streetNumber = mysqli_real_escape_string($db, trim($_POST['streetNumber']));
         $route = mysqli_real_escape_string($db, trim($_POST['route']));
         $suburb = mysqli_real_escape_string($db, trim($_POST['sublocality_level_1']));
         $city = mysqli_real_escape_string($db, trim($_POST['city']));
         $zipCode = mysqli_real_escape_string($db, trim($_POST['zipCode']));
         $province = mysqli_real_escape_string($db, trim($_POST['province']));
         $country = mysqli_real_escape_string($db, trim($_POST['country']));
         $email = mysqli_real_escape_string($db, trim($_POST['email']));
         if(!empty($streetNumber)  && !empty($route) && !empty($city) && !empty($province) && !empty($zipCode) && !empty($country)){
            $queryInsertMemberAddress = $db->prepare("INSERT INTO address (memberEmail, unitDetails, houseNumber, streetName, suburb, city, postalCode, province, country) VALUES (?,?,?,?,?,?,?,?,?)");
            $queryInsertMemberAddress->bind_param('ssisssiss', $email, $unitDetails, $streetNumber, $route, $suburb, $city, $zipCode, $province, $country);
            $queryInsertMemberAddress->execute() or die($queryInsertMemberAddress->error);
         }
      }
   }
}
When the script runs I don't get any errors but no rows are INSERTED in the database. I tried to find errors by doing the following:
- execute a var_dump on the $queryInsertMemberAddress after ->execute() and it returns - object(mysqli_stmt)[19] public 'affected_rows' => null public 'insert_id' => null public 'num_rows' => null public 'param_count' => null public 'field_count' => null public 'errno' => null public 'error' => null public 'error_list' => null public 'sqlstate' => null public 'id' => null
- execute a print_r on the $queryInsertMemberAddress variable after ->execute() and it returns - mysqli_stmt Object ( [affected_rows] => 1 [insert_id] => 28 [num_rows] => 0 [param_count] => 9 [field_count] => 0 [errno] => 0 [error] => [error_list] => Array ( ) [sqlstate] => 00000 [id] => 4
I can't understand why the print_r shows that one row was affected but no records show in the database. Does anyone see where I went wrong?
 
     
    