SQLite Forum

How to READ and WRITE an image to an SQLITE BLOB FIELD
Login
1) I don't see any PHP there.

2) Why are you doing a readfile inside an INSERT?

3) Why are you giving an example using the sqlite3 CLI program? If you want to do it in PHP, do it in PHP.

Something like this:

     $sql = 'update mytable set imgdata = ? where id = ?';
     $sth = $dbh->prepare ($sql);
     $result = $sth->bindValue (1, $blobdata, SQLITE3_BLOB);
     $result = $sth->bindValue (2, $id, SQLITE3_INTEGER);
     $res = $sth->execute ();

Adjust as appropriate. I've removed checks on $result to simplify.