php - MySQLi insert into prepare error -


hi inserted lot of stuff mysql databse.

but error in prepare statement. see database prepare error. doing wrong?

this code:

$sql = "insert                 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 this:

contact: - id    int(11)    auto_increment    primary key - ip    varchar(15) -    varchar(5) - name    varchar(20) - email    varchar(20) - subject    varchar(20) - text    varchar(600) 

for example to reserved word in mysql, should change code to:

$sql = "insert             `contact` (`ip`,`to`,`name`,`email`,`subject`,`text`)         values              ( ?, ?, ?, ?, ?, ? )        "; 

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -