Storing images into MySQL DB

This is a discussion on Storing images into MySQL DB within the PHP Language forums, part of the PHP Programming Forums category; I'm currently trying to store images into my DB. But the collation used on my DB is big5, since ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 07-27-2006
steelghost
 
Posts: n/a
Default Storing images into MySQL DB

I'm currently trying to store images into my DB. But the collation used
on my DB is big5, since my client wants this default encoding on their
webpage.
So to be able read the retreived data I have to use the command
mysql_query('SET NAMES big5');.

But when I do this, I'm not able to save the images to my DB. When I
attempt to, I recieve an SQL Error stating:

"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
'WƎ\\0G/-M3z...op\\07¿B4o^#Pu\\\'Z 揨Z2Qsf·'
at line 1"

If I changed the command to mysql_query('SET NAMES utf-8'); there are
no errors and the images save properly.

I suppose the encoding of the binary data in big5 contains some type of
invalid character causing the SQL string to error.

Anyone know how I can get around this?

Reply With Quote
  #2 (permalink)  
Old 07-27-2006
Jerry Stuckle
 
Posts: n/a
Default Re: Storing images into MySQL DB

steelghost wrote:
> I'm currently trying to store images into my DB. But the collation used
> on my DB is big5, since my client wants this default encoding on their
> webpage.
> So to be able read the retreived data I have to use the command
> mysql_query('SET NAMES big5');.
>
> But when I do this, I'm not able to save the images to my DB. When I
> attempt to, I recieve an SQL Error stating:
>
> "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
> 'WƎ\\0G/-M3z...op\\07¿B4o^#Pu\\\'Z 揨Z2Qsf·'
> at line 1"
>
> If I changed the command to mysql_query('SET NAMES utf-8'); there are
> no errors and the images save properly.
>
> I suppose the encoding of the binary data in big5 contains some type of
> invalid character causing the SQL string to error.
>
> Anyone know how I can get around this?
>


Are you using mysql_real_escape_string on the image before storing it?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 05:40 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0