Hi,

I am guessing that you default MySQL's charset to big5.
Switch to latin1 and try to insert the image again.  See if
the error still persists.

Why this error exists is beyond my knowledge though.
I am guessing that Perl DBI escapes ' \ in bind_param call.
And MySQL escapes the data again when using big5 charset,
which ultimate causes an error because of double escaping.

Let me show a test case which mimic your problem:

>From shell:

mysql test;
drop table if exists test;
create table test ( data varchar(10) );
quit

Back to shell:

cd /tmp;
echo ³\\ > data.txt
perl -MDBI -e 'my $dbh = 
DBI->connect("DBI:mysql:test;mysql_read_default_file=$ENV{HOME}/.my.cnf", undef, 
undef, { RaiseError =>
1 }); open(FILE, "data.txt"); read(FILE, my $data, -s "data.txt"); close(FILE); chomp 
$data; $dbh->prepare("INSERT INTO test
values(?)")->execute($data)'

Study the error message, you should get the idea as to
why you have problems inserting binary data into MySQL
when it's running using big5 as charset.

Regards,

Jindo

> -----Original Message-----
> From: Vincent Chen [mailto:[EMAIL PROTECTED]]
> Sent: Sunday, October 28, 2001 3:52 PM
> To: [EMAIL PROTECTED]
> Subject: Re: insert BLOB in perl
>
>
>
> Hi, Jeremy
>
> Thanks for your response. I got the following message
> while running perl script.
>
> -- output --
> processing DCP_0260.JPG
>
> size=148135
> DBD::mysql::st execute failed: You have an error in
> your SQL syntax near '9y\0
> ¡LY|?;sEiOo,EA~9iO?(9aJS~PAve??IRG`Z?NOXa;a\0cuOoweOQtWiC?I'
> at line 1 at ./upload line 54.
> -- output --
>
> Do you have any idea?
>
>
> Regards,
>
> Vincent Chen
>
>
> --- Jeremy Zawodny <[EMAIL PROTECTED]> wrote:
> > On Sat, Oct 27, 2001 at 09:08:40PM -0700, Vincent
> > Chen wrote:
> > >
> > > Dear all,
> > >
> > > It might be a FAQ, but bothered me several days.
> > I tried to insert
> > > a BLOB,acturally a picture, into a table. but
> > always got SQL error.
> >
> > But you haven't told us the error message you're
> > getting!
> >
> > Have you double-checked the DBI manual page?
> >
> > Jeremy
> > --
> > Jeremy D. Zawodny, <[EMAIL PROTECTED]>
> > Technical Yahoo - Yahoo Finance
> > Desk: (408) 349-7878   Fax: (408) 349-5454   Cell:
> > (408) 685-5936
> >
> > MySQL 3.23.41-max: up 52 days, processed
> > 1,161,021,649 queries (258/sec. avg)
>
>
> __________________________________________________
> Do You Yahoo!?
> Make a great connection at Yahoo! Personals.
> http://personals.yahoo.com
>
> ---------------------------------------------------------------------
> Before posting, please check:
>    http://www.mysql.com/manual.php   (the manual)
>    http://lists.mysql.com/           (the list archive)
>
> To request this thread, e-mail <[EMAIL PROTECTED]>
> To unsubscribe, e-mail <[EMAIL PROTECTED]>
> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
>
>


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to