MySQLi insert into prepare error
Posted
by
JPM
on Stack Overflow
See other posts from Stack Overflow
or by JPM
Published on 2012-06-04T16:37:00Z
Indexed on
2012/06/04
16:42 UTC
Read the original article
Hit count: 207
Hi I inserted a lot of stuff into a mysql databse.
But now I get an error in the prepare statement. I see Database prepare error. What am I doing wrong?
This is my Code:
$sql = "INSERT INTO
Contact (IP,To,Name,Email,Subject,Text)
VALUES
( ?, ?, ?, ?, ?, ? )
";
if (!$stmt = $db->prepare($sql)) {
echo 'Database prepare error';
exit;
}
$stmt->bind_param('ssssss', $ip_contact, $to_contact, $name_contact, $email_contact, $subject_contact, $text_contact);
if (!$stmt->execute()) {
echo 'Database execute error';
exit;
}
$stmt->close();
My SQL table looks like this:
Contact:
- ID int(11) auto_increment primary key
- IP varchar(15)
- To varchar(5)
- Name varchar(20)
- Email varchar(20)
- Subject varchar(20)
- Text varchar(600)
© Stack Overflow or respective owner