Hi I’m new to php mysql development. I’m using wamp server on windows. php5.3.4, mysql5.1, apache2.2. I try to execute this code but all I get is the error.php page. Is there a special way to insert in mysql if the table has auto_increment ids? In the code I give the NULL value for id.
Please help and please excuse my noob question!
function addMember($firstname, $lastname, $email, $password, $bday, $gender, $maritalStatus, $education, $occupation) {
$personalQ = "INSERT INTO users_personal_profile VALUES(NULL, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
if($stmt3 = $this->conn->prepare($personalQ)) {
$stmt3->bind_param('sssssssss', $firstname, $lastname, $email, $password, $bday, $gender, $education, $occupation, $maritalStatus);
$stmt3->execute();
if($stmt3->fetch()) {
$stmt3->close();
header("location: intermediate.php");
}
else {
$stmt3->close();
header("location: error.php");
}
}
}
Condensing the comments:
To see what’s happening you could adapt your script:
That should get you some insight in if there is an actual error and what it says.
The autoincrement-field should be set in your db scheme. How is your table defined? Is the first field actually marked as autoincrement? (If it is, null should work.)
You can also execute the query directly into the database and see how it does. (You could use phpmyadmin or navicat or sql from the console for that.)
If you need the autoincrement value in the code, you can access it with
$mysqli_stmt->insert_id;