Storing images into MySQL DB

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • steelghost

    #1

    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('SE T 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ÇÆŽ‡ÿ\\0µGÂé/ä-ÉM3Äzõ·...oŒý†Í péãžÿ\\07¿B4o è^#³‹PÐu\\\'Z ²¸ŒÉ揨Zê¶2Qs f·Œ'
    at line 1"

    If I changed the command to mysql_query('SE T 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?

  • Jerry Stuckle

    #2
    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('SE T 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ÇÆŽ‡ÿ\\0µGÂé/ä-ÉM3Äzõ·...oŒý†Í péãžÿ\\07¿B4o è^#³‹PÐu\\\'Z ²¸ŒÉ揨Zê¶2Qs f·Œ'
    at line 1"
    >
    If I changed the command to mysql_query('SE T 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_esca pe_string on the image before storing it?

    --
    =============== ===
    Remove the "x" from my email address
    Jerry Stuckle
    JDS Computer Training Corp.
    jstucklex@attgl obal.net
    =============== ===

    Comment

    Working...