Domanda

I'm trying to save a byteArray of a jpg from an as3 project through amfphp to then use php/mySQL to save it to a BLOB on my database. Here's my php function

function saveImage($uid, $name, $tag1, $tag2, $tag3, $ba) {
        $result = mysql_query("INSERT INTO images (uid,name,tag1,tag2,tag3,thumb) VALUES ('$uid','$name','$tag1','$tag2','$tag3','$ba->data');");

        $error = mysql_error();
        if ($error) {
            return $error;
        }
        else {
            return $result;
        }
    }

but i keep getting this error back:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz¢£¤¥¦§¨©ª²³´µ¶·¸¹ºÂÃÄ' at line 1

Any suggestions on how to resolve this?

È stato utile?

Soluzione

For future reference, if you want to save binary file to blob cell in mysql, you can use addslashes function to your data, like:

addslashes($blob_data);

An example of working code is located here: try addslashes on binary data variable. addslashes($variable)

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top