0

I did see a few posts up here that have similar issues and I tried a few of the answers but nothing really works for me.

    public function upload_image3($post_array,$primary_key)
{
    $szFile=str_replace("/files/","/thumbnails/",$post_array['thumbnail_url']);
    $file_types = array( ".doc", ".ppt", ".pdf", ".xls", ".jpg");
    $szFile=str_replace($file_types,".png",$szFile);
    $szFile3 = file_get_contents($szFile);
    $imgData = addslashes($szFile3);
    $BLOB_insert = array(
        "id" => $primary_key,
        "image_BLOB" => $imgData
    );
    $iRc=$this->db->update($_SESSION[table],$BLOB_insert);
    return;
}

I have an image locally on my drive and it arrives via the $post_array. I am trying to save it in a BLOB field in my RDS mysql table. My code is above. I have both the original file (doc or ppt or xls) and I also has a thumbnail of it (same name, just ending in .png) and in the /thumbnails dir. Everything works fine until the update. The return code from the update is NULL. And then when I look in the table with mysqlWorkBench, it appears to still be NULL. So the update is not working and I don't know why or where to look for an error code.

In viewing the local error.log I see that I got the following error: Query error: Invalid utf8 character string: '\x89PNG' - Invalid query: UPDATE substantiator.word SET image_BLOB = �PNG

This makes me think that the default collation was not setup correctly for the USA. I am thinking that if I can modify the default collation (and maybe recreate the BLOB columns) then perhaps this will work. But how to do that on RDS?

  • This question has nothing to do with mysql workbench. – Shadow Mar 20 '21 at 20:11
  • Are you sure it is uodate you need and not insert? – Shadow Mar 20 '21 at 20:12
  • Originally I had insert. The record is already up there. This is in a callback that gets called AFTER insert. Also, if I could see the BLOB in mysqlWorkbench I could be sure that it was not updated correctly. –  Mar 20 '21 at 20:20
  • Does this answer your question? [Is a BLOB converted using the current/default charset in MySQL?](https://stackoverflow.com/questions/14734812/is-a-blob-converted-using-the-current-default-charset-in-mysql) – glovemobile Mar 21 '21 at 17:15
  • No it doesn't. I still can't get the insert or update to work. –  Mar 24 '21 at 21:54

0 Answers0