문제

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?

도움이 되었습니까?

해결책

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)

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top