user3407447
user3407447

Reputation: 17

MySQL query is not inserting data into the table

        $stmt= $mysqli->prepare("insert into book_project.personal_details(name,email,cc_num,address,city,zipcode) values (?,?,?,?,?,?)");

        var_dump($_SESSION);

        $stmt->bind_param('ssssss',$_SESSION['name'],$_SESSION['email'],$_SESSION['cc_num'],$_SESSION['address'],$_SESSION['city'],$_SESSION['zipcode']);

        $stmt->execute();

        $stmt->close();
}   

I have a id column as primary key have not included it. id auto increments. I do not know to find errors. I do not understand what is happening.

Upvotes: 0

Views: 51

Answers (1)

user3577953
user3577953

Reputation:

You have 7 parameters here:

$stmt->bind_param('ssssss',$_SESSION['name'],$_SESSION['email'],$_SESSION['cc_num'],$_SESSION['address'],$_SESSION['city'],$_SESSION['zipcode']);

But there are only 6 placeholders in the SQL query:

$stmt= $mysqli->prepare("insert into book_project.personal_details(name,email,cc_num,address,city,zipcode) values (?,?,?,?,?,?)");

Upvotes: 2

Related Questions