Re: Insert blob data using prepared statements
On 7/26/2010 2:30 AM, Manasi Save wrote: Hi All, I need to insert Blob data in my table using prepared statements. But Whenever I try to insert it using prepared statement it is giving me mysql syntax error. Here's the prepared statement :- SET @stmt = Concat(Insert into ',mydb,'.MyTable(MyData, MyID) Select ','',Inputdata,'',',',InputID,';'); Prepare stmt1 From @stmt; Execute stmt1; Deallocate prepare stmt1; The executing statement looks like this :- Insert into `mydb`.MyTable(MyData, MyID) Select ** STREAM DATA **, 1; This gives me an error saying mysql syntax near ** STREAM DATA.. Can anyone give me any example how to insert blob data in database with prepared statement. First, have you tried using INSERT ... VALUES ... instead of INSERT ... SELECT ... ? Second, have you tried passing the STREAM data into the EXECUTE command as a parameter? One of the nice things about prepared statements is their ability to substitute data into the statement at runtime. For example, your statement could be 'INSERT INTO `mydb`.MyTable(MyID, MyDATA) VALUES (?,?)' and your execute could be EXECUTE stmt1 (1, 'stream data'); Depending on how you connect, you may also be able to bind one of those ? parameters to a variable in your code. That would completely eliminate the need to copy and escape your data into a quoted string literal. Third, you must always be aware of the max_allowed_packet size for the connection you are on. If you attempt to send a command larger than that size, the server will forcibly disconnect your session under the impression that you are attempting to sabotage the machine by sending queries that are too large. -- Shawn Green MySQL Principal Technical Support Engineer Oracle USA, Inc. Office: Blountville, TN -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/mysql?unsub=arch...@jab.org
Insert blob data using prepared statements
Hi All, I need to insert Blob data in my table using prepared statements. But Whenever I try to insert it using prepared statement it is giving me mysql syntax error. Here's the prepared statement :- SET @stmt = Concat(Insert into ',mydb,'.MyTable(MyData, MyID) Select ','"',Inputdata,'"',',',InputID,';'); Prepare stmt1 From @stmt; Execute stmt1; Deallocate prepare stmt1; The executing statement looks like this :- Insert into `mydb`.MyTable(MyData, MyID) Select ** STREAM DATA **, 1; This gives me an error saying mysql syntax near ** STREAM DATA.. Can anyone give me any example how to insert blob data in database with prepared statement. Thanks in advance. --Regards, Manasi Save Artificial Machines Private Limited manasi.s...@artificialmachines.com Ph:-9833537392
how to insert blob data remotely
Hi all!.. How can I insert blob data (specifically a jpg image) into a blob field remotely?.. I mean, the client has to choose a jpg image in his/her PC and upload it to the server. I found this piece of code: INSERT INTO car_models (Brand, Picture) VALUES ('Subaru Impreza', LOAD_FILE('/somepath/impreza.jpg')); But LOAD_FILE only works if 'picture.jpg' is placed on the same machine where the server is running. Any Idea? Thanks in Advance Hector. -- Ing. Hctor Maldonado Melgar Dpto. Desarrollo de Software TCI S.A., Lima-Per [EMAIL PROTECTED] Of.: 421-3222 Cel: 9503-9205 -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: how to insert blob data remotely
On Thu, 2004-07-01 at 11:06, Héctor Maldonado wrote: But LOAD_FILE only works if 'picture.jpg' is placed on the same machine where the server is running. That makes sense. You could of course NFS mount from the remote machine to the machine you are working from but that is much the same thing. Alternatively if you are working in a language like Perl there are other tricks you can play... -- Peter L. Berghold[EMAIL PROTECTED] Dog event enthusiast, brewer of Belgian (style) Ales. Happiness is having your contented dog at your side and a Belgian Ale in your glass. -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
RE: how to insert blob data remotely
Is using a programming language such as Java, PHP or VB an option? -Original Message- From: Hctor Maldonado To: [EMAIL PROTECTED]; Omar De la Cruz Sent: 7/1/04 10:06 AM Subject: how to insert blob data remotely Hi all!.. How can I insert blob data (specifically a jpg image) into a blob field remotely?.. I mean, the client has to choose a jpg image in his/her PC and upload it to the server. I found this piece of code: INSERT INTO car_models (Brand, Picture) VALUES ('Subaru Impreza', LOAD_FILE('/somepath/impreza.jpg')); But LOAD_FILE only works if 'picture.jpg' is placed on the same machine where the server is running. Any Idea? Thanks in Advance Hector. -- Ing. Hctor Maldonado Melgar Dpto. Desarrollo de Software TCI S.A., Lima-Per [EMAIL PROTECTED] Of.: 421-3222 Cel: 9503-9205 -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED] -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: how to insert blob data remotely.. SOLVED :)
Hi Again.. Fortunately I found a way to do this using C++/Qt. Here's the code for who are interested in: QFile *myFile; QSqlQuery query; QString strQuery; QByteArray myByteArray; // open the image and fill the bytearray myFile = new QFile(/root/hm/variostepsa/fotos_marcopolo/paradiso1.jpg); myFile-open(IO_ReadOnly); myByteArray = myFile-readAll(); myFile-close(); // Insert the image strQuery = INSERT INTO Model (Brand, Picture) VALUES ('Subaru', :pic); query.prepare(strQuery); query.bindValue(:pic, myByteArray); if (!query.exec()) qWarning(Eorrr); I don't know if this is optimal, but it works.. :) Thanks to all those reply.. Regards, Hector. El jue, 01-07-2004 a las 20:32, Peter L. Berghold escribi: On Thu, 2004-07-01 at 11:06, Hctor Maldonado wrote: But LOAD_FILE only works if 'picture.jpg' is placed on the same machine where the server is running. That makes sense. You could of course NFS mount from the remote machine to the machine you are working from but that is much the same thing. Alternatively if you are working in a language like Perl there are other tricks you can play... -- Ing. Hctor Maldonado Melgar Dpto. Desarrollo de Software TCI S.A., Lima-Per [EMAIL PROTECTED] Of.: 421-3222 Cel: 9503-9205 -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
fail to insert BLOB data on multibyte charset MySQL server
failed to insert BLOB data on multibyte charset i'm using GBK charset. mysql 4.01 use PHP to insert, did addslashes before insert however, failed. i've read the mysql_escape_string() source code. noticed that, mb char is processed differently, but is it a must ? yes, php+libmysql is not up to date, but i'm trying to use my own escaping function function GBK_escape_string($data) { $ret = ''; $l = strlen($data); for ($i = 0; $i $l; $i ++) { $c = ord($data{$i}); if (0x81 = $c $c = 0xfe ($i+1) $l) { $c2 = ord($data{$i+1}); if ((0x40=$c2 $c2=0x7e) || (0x80=$c2 $c2=0xfe)) { $ret .= $data{$i}; $ret .= $data{++$i}; continue; } } switch ($data{$i}) { case \\: $ret .= ; break; case \0: $ret .= \\0; break; case \n: $ret .= \\n; break; case \r: $ret .= \\r; break; case ': $ret .= \\'; break; case \: $ret .= \\\; break; case \032: $ret .= \\Z; break; default: $ret .= $data{$i}; break; } } return $ret; } still won't work anyone could give me a hand? i'm supposing the error: string: \n\xE0'. according to ctype-gbk.c ismbchar_gbk \xE0' is not mbchar, \xE0 should not escape, and ' should escaped. result: \x5Cn\xE0\x5C'\x5C. (0x5C is backslash) when mysqld scanning this string \x5Cn is scan as \n, correct but \xE0\x5C is scan as a GBK char, then ' will be a string terminator and complain that SQL syntax near '\' which is the escaped double-quote ...0x5C... _ ÓëÁª»úµÄÅóÓѽøÐн»Á÷£¬ÇëʹÓà MSN Messenger: http://messenger.microsoft.com/cn/ - 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
Re: Fw: insert BLOB values
Hytham, Saturday, June 22, 2002, 12:37:21 AM, you wrote: i have a column of type blob, that i wish to store images in it, but how can i right the sql statement to insert the image? i mean : insert into tblImages set imageField = ??? where id=999 It's not a correct statement, use UPDATE instead of INSERT. now what the ??? should be ? If images are stored on the server, you can use LOAD_FILE() function: http://www.mysql.com/doc/S/t/String_functions.html f.e. UPDATE tblImages SET imageField = LOAD_FILE('/full/path/to/the/file') WHERE id = 999; -- For technical support contracts, goto https://order.mysql.com/?ref=ensita This email is sponsored by Ensita.net http://www.ensita.net/ __ ___ ___ __ / |/ /_ __/ __/ __ \/ /Victoria Reznichenko / /|_/ / // /\ \/ /_/ / /__ [EMAIL PROTECTED] /_/ /_/\_, /___/\___\_\___/ MySQL AB / Ensita.net ___/ www.mysql.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
Fw: insert BLOB values
- Original Message - From: Hytham Shehab [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Saturday, June 22, 2002 12:15 AM Subject: Fw: insert BLOB values - Original Message - From: Hytham Shehab [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, June 21, 1999 11:06 PM Subject: insert BLOB values hi all of you, i have a column of type blob, that i wish to store images in it, but how can i right the sql statement to insert the image? i mean : insert into tblImages set imageField = ??? where id=999 now what the ??? should be ? thx guys. -- Hytham Shehab - 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
INSERT blob data in C
Howdy - I looked in the doc @ mysql.com and the New Riders and O'Reilly MySQL books. Plus, I consulted the archives as best I could and did not see an answer for this: How do you insert binary data using the C API? I know you need to use mysql_real_query method and pass length, but how do you delimit the blob field? INSERT INTO some_table (key_field,blob_field) VALUES ( 'A', 'binary data'); INSERT INTO some_table SET key_field = 'A', blob_field = 'binary data'; Both have the issue of having the single quote appear in the data. These fields I'm storing are between 10 and 2000 bytes long and there are millions of them so I can't store them as separate files and then use the file name like I would for a graphic or downloadable file on a web page. TIA! Have A Great Scouting Day Ken Hylton 7826 Falcon Ridge Drive San Antonio, Texas 78239-4032 210-646-9508 (home) 210-949-7261 (work) 210-949-7254 (fax) 210-287-6756 (cell) [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] - 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
Re: INSERT blob data in C
just some code I did some time ago: /* */ #include stdio.h #include stdlib.h #include unistd.h #include fcntl.h #include sys/fcntl.h #include mysql/mysql.h MYSQL dbcon; int main(int argc, char *argv[]) { int i; char *tmpQ=malloc(2*1024*1024); char *end; int file; int size; char *mem; char tmpstr[1024]; mysql_init(dbcon); mysql_real_connect(dbcon, NULL, username, password, dbname,0,/tmp/mysql.sock,0); for(i=1;iargc;i++) { file = open(argv[i], O_RDONLY); lseek(file, 0, SEEK_SET); size = lseek(file, 0, SEEK_END); lseek(file, 0, SEEK_SET); mem = malloc(size); read(file,mem,size); printf(inserting: %s\n,argv[i]); end = (char *) strmov(tmpQ,INSERT INTO image values(); *end++ = '\''; sprintf(tmpstr,%i,i); end = strmov(end, tmpstr); *end++ = '\''; *end++ = ','; *end++ = '\''; sprintf(tmpstr,%i,i); end = strmov(end, tmpstr); *end++ = '\''; *end++ = ','; *end++ = '\''; end += mysql_escape_string(end, mem, size); *end++ = '\''; *end++ = ')'; mysql_real_query(dbcon, tmpQ, (unsigned int) (end - tmpQ)); free(mem); close(file); } mysql_close(dbcon); exit(0); return 0; } Kenneth Hylton wrote: Howdy - I looked in the doc @ mysql.com and the New Riders and O'Reilly MySQL books. Plus, I consulted the archives as best I could and did not see an answer for this: How do you insert binary data using the C API? I know you need to use mysql_real_query method and pass length, but how do you delimit the blob field? INSERT INTO some_table (key_field,blob_field) VALUES ( 'A', 'binary data'); INSERT INTO some_table SET key_field = 'A', blob_field = 'binary data'; Both have the issue of having the single quote appear in the data. These fields I'm storing are between 10 and 2000 bytes long and there are millions of them so I can't store them as separate files and then use the file name like I would for a graphic or downloadable file on a web page. TIA! Have A Great Scouting Day Ken Hylton 7826 Falcon Ridge Drive San Antonio, Texas 78239-4032 210-646-9508 (home) 210-949-7261 (work) 210-949-7254 (fax) 210-287-6756 (cell) [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] - 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
RE: INSERT blob data in C
Thanks for your quick response! That's just what I needed. The secret is using mysql_escape_string to change the data such that it will not cause problems with delimiters! Thank You! Have A Great Scouting Day Ken Hylton 7826 Falcon Ridge Drive San Antonio, Texas 78239-4032 210-646-9508 (home) 210-949-7261 (work) 210-949-7254 (fax) 210-287-6756 (cell) [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] -Original Message- From: paradoxix [mailto:[EMAIL PROTECTED]] Sent: Thursday, February 28, 2002 3:04 PM To: Kenneth Hylton Cc: [EMAIL PROTECTED] Subject:Re: INSERT blob data in C just some code I did some time ago: /* */ #include stdio.h #include stdlib.h #include unistd.h #include fcntl.h #include sys/fcntl.h #include mysql/mysql.h MYSQL dbcon; int main(int argc, char *argv[]) { int i; char *tmpQ=malloc(2*1024*1024); char *end; int file; int size; char *mem; char tmpstr[1024]; mysql_init(dbcon); mysql_real_connect(dbcon, NULL, username, password, dbname,0,/tmp/mysql.sock,0); for(i=1;iargc;i++) { file = open(argv[i], O_RDONLY); lseek(file, 0, SEEK_SET); size = lseek(file, 0, SEEK_END); lseek(file, 0, SEEK_SET); mem = malloc(size); read(file,mem,size); printf(inserting: %s\n,argv[i]); end = (char *) strmov(tmpQ,INSERT INTO image values(); *end++ = '\''; sprintf(tmpstr,%i,i); end = strmov(end, tmpstr); *end++ = '\''; *end++ = ','; *end++ = '\''; sprintf(tmpstr,%i,i); end = strmov(end, tmpstr); *end++ = '\''; *end++ = ','; *end++ = '\''; end += mysql_escape_string(end, mem, size); *end++ = '\''; *end++ = ')'; mysql_real_query(dbcon, tmpQ, (unsigned int) (end - tmpQ)); free(mem); close(file); } mysql_close(dbcon); exit(0); return 0; } Kenneth Hylton wrote: Howdy - I looked in the doc @ mysql.com and the New Riders and O'Reilly MySQL books. Plus, I consulted the archives as best I could and did not see an answer for this: How do you insert binary data using the C API? I know you need to use mysql_real_query method and pass length, but how do you delimit the blob field? INSERT INTO some_table (key_field,blob_field) VALUES ( 'A', 'binary data'); INSERT INTO some_table SET key_field = 'A', blob_field = 'binary data'; Both have the issue of having the single quote appear in the data. These fields I'm storing are between 10 and 2000 bytes long and there are millions of them so I can't store them as separate files and then use the file name like I would for a graphic or downloadable file on a web page. TIA! Have A Great Scouting Day Ken Hylton 7826 Falcon Ridge Drive San Antonio, Texas 78239-4032 210-646-9508 (home) 210-949-7261 (work) 210-949-7254 (fax) 210-287-6756 (cell) [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] - 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
RE: insert BLOB in perl
On Mon, 29 Oct 2001, Jindo Soul wrote: 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. Well, its not that MySQL does any escaping but you're basically right. The DBD::mysql driver will escape all instances of the backslash. If the backslash is the last character in a string _and_ the last part of the string represents a multibyte big5 character, there's a problem. Perl turns 'A\' into 'A\\'. But MySQL will see that as 'A\' plus '\''. In other words, the second backslash is seen as escaping the single quote, leaving the quote not terminated. I tried patching the DBD::mysql code a year or so back but my C skills are very weak and I couldn't quite get it. I still have the patches somewhere if someone more skilled than me wants to take a crack at it. Basically, I was looking to add a 'mysql_wide_charset' option that could be passed to the driver. Nowadays, it might be better if instead it just checked with the server as soon as it connects (though that only works for newer MySQLs). -dave /*== www.urth.org We await the New Sun ==*/ - 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
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 '9ÿ\0 ¨Ý¦»;ßÈïÓõ,EÂ~9íÒ¬(9àJS~PÃve Ï®G`Z¾NÒXã;ã\0çúÓºwéÓQtWîCÏ' 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
RE: insert BLOB in perl
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
insert BLOB in perl
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. this is what I do. $sth=$dbh-prepare(insert into photo values (?,?)); $sth-bind_param(1,'2001-10-27'); $sth-bind_param(2,$image,SQL_BINARY); $sth-execute; Please correct me or provide a code sample. Thanks, Vincent Chen __ 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
Re: insert BLOB in perl
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) - 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
Re: could not insert BLOB data type in a table
PD At 10:43 AM +0530 7/25/01, [EMAIL PROTECTED] wrote: Hi, I just want to know how to insert a BLOB data type in a field of a table. I want to put the binary data stream not the file link in the filed. The language i m using is PERL5. PD Use $dbh-quote() or placeholders to insert the BLOB value into PD the query string. See the DBI docs. Only use placeholders. $dbh-quote() is unreliable (and this fact is documented in DBI documentation). -- -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- | Ilya Martynov (http://martynov.org/)| | GnuPG 1024D/323BDEE6 D7F7 561E 4C1D 8A15 8E80 E4AE BE1A 53EB 323B DEE6 | | AGAVA Software Company (http://www.agava.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
Re: could not insert BLOB data type in a table
At 5:23 PM +0400 7/25/01, Ilya Martynov wrote: PD At 10:43 AM +0530 7/25/01, [EMAIL PROTECTED] wrote: Hi, I just want to know how to insert a BLOB data type in a field of a table. I want to put the binary data stream not the file link in the filed. The language i m using is PERL5. PD Use $dbh-quote() or placeholders to insert the BLOB value into PD the query string. See the DBI docs. Only use placeholders. $dbh-quote() is unreliable (and this fact is documented in DBI documentation). Please show me the part of the documentation that you're referring to, and please supply a counter-example. quote() is extremely useful for producing SQL statements that will be executed by another program, a situation for which placeholders are useless. -- -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- | Ilya Martynov (http://martynov.org/)| | GnuPG 1024D/323BDEE6 D7F7 561E 4C1D 8A15 8E80 E4AE BE1A 53EB 323B DEE6 | | AGAVA Software Company (http://www.agava.com/) | -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- -- Paul DuBois, [EMAIL PROTECTED] - 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
Re: could not insert BLOB data type in a table
Only use placeholders. $dbh-quote() is unreliable (and this fact is documented in DBI documentation). PD Please show me the part of the documentation that you're referring to, PD and please supply a counter-example. quote() is extremely useful for PD producing SQL statements that will be executed by another program, a PD situation for which placeholders are useless. perldoc DBI: Quote will probably not be able to deal with all pos- sible input (such as binary data or data containing newlines), .. There is no need to quote values being used with the Placeholders and Bind Values entry elsewhere in this document. Here a proof that quote sucks: http://lists.mysql.com/cgi-ez/ezmlm-cgi?1:msp:73935:phlgjhgmdiikjknclakk User had trobles with quote and binary data but once he rewrote code with placeholders problem disappeared. -- -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- | Ilya Martynov (http://martynov.org/)| | GnuPG 1024D/323BDEE6 D7F7 561E 4C1D 8A15 8E80 E4AE BE1A 53EB 323B DEE6 | | AGAVA Software Company (http://www.agava.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
could not insert BLOB data type in a table
Hi, I just want to know how to insert a BLOB data type in a field of a table. I want to put the binary data stream not the file link in the filed. The language i m using is PERL5. Thanks in advance. Regards, Thakur Gyawali Nepal - 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
Re: could not insert BLOB data type in a table
At 10:43 AM +0530 7/25/01, [EMAIL PROTECTED] wrote: Hi, I just want to know how to insert a BLOB data type in a field of a table. I want to put the binary data stream not the file link in the filed. The language i m using is PERL5. Use $dbh-quote() or placeholders to insert the BLOB value into the query string. See the DBI docs. Thanks in advance. Regards, Thakur Gyawali Nepal -- Paul DuBois, [EMAIL PROTECTED] - 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
Insert BLOB
Hello there, I'm currently developing an app in VB with MySQL as the database and I'm having a hard time inserting a BLOB into MySQL. Can somebody share with me a code snippet on how to do this? Thanks, Eric