1
$q = $con->prepare("INSERT INTO messages (time, sender_id, recipient_id, read, subject, content, status) VALUES (?, ?, ?, ?, ?, ?, ?)");
$q->execute(array($date->format('U'), $ID, $_POST['to'], "0", $_POST['subject'], $_POST['content'], 1));
$count = $stmt->rowCount();
echo $count;

This code does not actually insert anything in the database. No error, and it even echo's 1, meaning it did work. But nothing shows up in my database.

If i add: or die(print_r($stmt->errorInfo(), true)) to the end of the execute line, it outputs: Array ( [0] => 00000 [1] => [2] => ) which I'm not really sure what that means.

Any idea? I know how pdo works and really can not figure this out.

Halvor Holsten Strand
  • 19,829
  • 17
  • 83
  • 99
  • Try `$q->errorInfo()` and `$q->rowCount()`. – Barmar Aug 02 '14 at 04:24
  • 3
    `read` is a [mysql reserved word](http://dev.mysql.com/doc/refman/5.5/en/reserved-words.html) that needs to be escaped with backticks `$q = $con->prepare("INSERT INTO messages (time, sender_id, recipient_id, \`read\`, subject, content, status) VALUES (?, ?, ?, ?, ?, ?, ?)");` – Sean Aug 02 '14 at 04:24
  • Sean, that was it! thanks! – Francis Smith Aug 02 '14 at 04:29

0 Answers0