-3

This code doesn't throw any errors at all but when I would check the result to the database, there are no new rows added. Please help

$stmt = $conn->prepare("INSERT INTO users (first_name, last_name, dept_id, contact_no, email, username, password, position_apply_first, position_apply_second, date_of_application, city_address, permanent_address, residence_no, office_no, date_of_birth, marital_status, religion, sex, sss_no, tin_no, pagibig_no, philhealth_no, prc_no, hobbies, language_fair, language_fluent) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
$stmt->bind_param("ssssssssssssssssssssssssss", $first_name, $last_name, $department, $contact_no, $email, $user, $pass, $apply_first, $apply_second, $date_of_application, $city_address, $permanent_address, $residence_no, $office_no, $date_of_birth, $marital_status, $religion, $sex, $sss_no, $tin_no, $pagibig_no, $philhealth_no, $prc_no, $hobbies, $language_fair, $language_fluent);
// insert one row
$first_name = $_POST["reg-firstname"];
$last_name = $_POST["reg-lastname"];
$department = $_POST["reg-dept"];
$contact_no = $_POST["reg-mobile"];
$email = $_POST["reg-emailAddress"];
$user = $_POST["reg-username"];
$pass = $_POST["reg-password1"];
$apply_first = $_POST["first_choice"];
$apply_second = $_POST["second_choice"];
$date_of_application = $_POST["reg-applicationdate"];
$city_address = $_POST["reg-cityaddress"];
$permanent_address = $_POST["reg-permanentaddress"];
$residence_no = $_POST["reg-residence"];
$office_no = $_POST["reg-office"];
$date_of_birth = $_POST["reg-dateofbirth"];
$marital_status = $_POST["reg-maritalstatus"];
$religion = $_POST["reg-religion"];
$sex = $_POST["reg-sex"];
$sss_no = $_POST["reg-sssno"];
$tin_no = $_POST["reg-tinno"];
$pagibig_no = $_POST["reg-pagibigno"];
$philhealth_no = $_POST["reg-philhealthno"];
$prc_no = $_POST["reg-prcno"];
$hobbies = $_POST["reg-hobbies"];
$language_fair = $_POST["reg-languagefair"];
$language_fluent = $_POST["reg-languagefluent"];

$stmt->execute();
$conn->close();
Earvine
  • 1
  • 3
  • You don't check for errors, hence you don't see it. One possible approach: `$res = $stmt->execute(); if (!$res) { var_dump($stmt->error); exit(); }` – raina77ow Sep 29 '15 at 08:22

1 Answers1

2

This code doesn't throw any errors at all

Because You don't check for any errors at all and we certainly will be guessing what it is while you can easily check for errors and find out what.

printf("Error: %s.\n", $stmt->error);

Manual

Hanky Panky
  • 46,730
  • 8
  • 72
  • 95