List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:February 1 2002 5:57pm
Subject:Re: LOAD_FILE over SMB filesystems
View as plain text  
At 17:47 +0000 2/1/02, Kevin Smith wrote:
>I don't get an error message... I'm actually running the script from the
>shell > prompt, so I'm totally mystified about why it's not working.

Umm, actually it is working, according to the trace below.  execute()
returns "0E0", which means the statement succeeded and update 0 rows.
(Otherwise you'd get back under or the DBI would throw an exception,
depending on whether you have RaiseError enabled.)

So, either:
- no row has an id value of 1, or
- the row with an id value of 1 already has the exactly same image value,
   in which case MySQL knows that it's not actually changing the current
   value, and reports "no rows changed".

Assuming you have a row with id = 1, clear out the existing image
value manually: UPDATE banners SET image = '' WHERE id = 1;

Then try your script ag'in and see what happens.

>
>Here is the DBI debug :
>
>[root@server1 cgi-bin]# perl blob.cgi
>     DBI::db=HASH(0x81b34a0) trace level set to 2 in DBI 1.14-nothread
>     Note: perl is running without the recommended perl -w option
>     -> prepare for DBD::mysql::db (DBI::db=HASH(0x81b34b8)~0x81b34a0 'UPDATE
>banners SET banners.image =
>LOAD_FILE('/var/www/htdocs/corporate/images/homenew.jpg') where
>banners.id=1')
>Setting mysql_use_result to 0
>     <- prepare= DBI::st=HASH(0x8196e48) at blob.cgi line 17.
>     -> trace in DBD::_::common for DBD::mysql::st
>(DBI::st=HASH(0x8196e48)~0x81bcd04 2)
>     <- trace= 2 at blob.cgi line 18.
>     -> execute for DBD::mysql::st (DBI::st=HASH(0x8196e48)~0x81bcd04)
>     -> dbd_st_execute for 081bccf8
>     <- dbd_st_execute 0 rows
>     <- execute= '0E0' at blob.cgi line 20.
>     -> finish for DBD::mysql::st (DBI::st=HASH(0x8196e48)~0x81bcd04)
>     <- finish= 1 at blob.cgi line 25.
>     -> disconnect for DBD::mysql::db (DBI::db=HASH(0x81b34b8)~0x81b34a0)
>imp_dbh->svsock: 8150e5c
>     <- disconnect= 1 at blob.cgi line 26.
>     -> DESTROY for DBD::mysql::st (DBI::st=HASH(0x81bcd04)~INNER)
>     <- DESTROY= undef during global destruction.
>     -> DESTROY for DBD::mysql::db (DBI::db=HASH(0x81b34a0)~INNER)
>     <- DESTROY= undef during global destruction.
>
>----- Original Message -----
>From: "Paul DuBois" <paul@stripped>
>To: "Kevin Smith" <kevin@stripped>
>Cc: <mysql@stripped>
>Sent: Friday, February 01, 2002 5:43 PM
>Subject: Re: LOAD_FILE over SMB filesystems
>
>
>>  At 17:41 +0000 2/1/02, Kevin Smith wrote:
>>  >Yes, it definitely is... I'm running Apache 1.3.22 on Linux RedHat 7.1
>and
>>  >MySQL 3.23.47.
>>
>>  Does the script connect to the MySQL server using a MySQL account
>>  that has the FILE privilege?
>>
>>  By the way, you didn't report the error message that you get.
>>  What is it?
>>
>>  >
>>  >----- Original Message -----
>>  >From: "Paul DuBois" <paul@stripped>
>>  >To: "Gerald Clark" <gerald_clark@stripped>; "Kevin Smith"
>>  ><ksmith@stripped>
>>  >Cc: <mysql@stripped>
>>  >Sent: Friday, February 01, 2002 5:37 PM
>>  >Subject: Re: LOAD_FILE over SMB filesystems
>>  >
>>  >
>>  >>  At 11:32 -0600 2/1/02, Gerald Clark wrote:
>>  >>  >The single quotes around $image prevent perl from substituting
> the
>value.
>>  >>  >You are trying to load a file named $imageFN.
>>  >>  >$SQL = "UPDATE banners SET image=load_file(\"$imageFN\") where
> id=1";
>>  >>
>>  >>  But the single quotes are within a double-quoted string.  So
> shouldn't
>>  >>  the substitution still occur?
>>  >>
>>  >>  Is the web server running on the same host as the MySQL server?
>>  >>
>>  >>  >
>>  >>  >Kevin Smith wrote:
>>  >>  >
>>  >>  >>After reading some other posts on inserting a image into a
> blob
>field, I
>>  >>  >>tried using DBI to insert and the following does not work...
>>  >>  >>
>>  >>  >>I've double-checked the path and it is correct.
>>  >>  >>
>>  >>  >>$imageFN = '/var/www/htdocs/corporate/images/homenew.jpg';
>>  >>  >>$SQL = "UPDATE banners SET image=load_file('$imageFN') where
> id=1";
>>  >>  >>
>>  >>  >>If I execute the same SQL statement at the MySQL > prompt
> it inserts
>>  >into
>>  >>  >>the database fine... what am I doing wrong?
>  > >>  >>
>>  >>  >>Thanks,
>>  >>  >>
>>  >  > >>Kevin
>>
>>
>>

Thread
LOAD_FILE over SMB filesystemsEgor Egorov23 Jan
  • Re: LOAD_FILE over SMB filesystemsStephen Lee23 Jan
  • Re: LOAD_FILE over SMB filesystemsKevin Smith1 Feb
  • Re: LOAD_FILE over SMB filesystemsGerald Clark1 Feb
    • Re: LOAD_FILE over SMB filesystemsPaul DuBois1 Feb
  • Re: LOAD_FILE over SMB filesystemsKevin Smith1 Feb
  • Re: LOAD_FILE over SMB filesystemsKevin Smith1 Feb
    • Re: LOAD_FILE over SMB filesystemsPaul DuBois1 Feb
  • Re: LOAD_FILE over SMB filesystemsKevin Smith1 Feb
    • Re: LOAD_FILE over SMB filesystemsPaul DuBois1 Feb
      • [ANN] LASSO SUMMIT 2002 EUROPEJim Van Heule1 Feb
        • Re: [ANN] LASSO SUMMIT 2002 EUROPEBlue World Lasso Evangelist)1 Feb
  • Re: LOAD_FILE over SMB filesystemsGerald Clark1 Feb
  • Re: LOAD_FILE over SMB filesystemsKevin Smith1 Feb