Hi
I asked the same Q a while ago about bin data if you look in the archives of
this list it should still be there look under "binary data" as the subject
To point you in the right direction tho here are some excerpts from my
answers that I kept...
if you look at the second excerpt there is a perl example to laod the data,
but I think that there is a function called loadfile() I think and you can
use this too! I just remember seeing it, but I forgot to save that message
:-( Apparently it escapes all your bin zeros, ", \ etc although after lots
of discussions with other ppl we decided it is better to have a reference to
the files instead of storing the actual file on the DB, although ppl, do
still find it useful to do it, we didnt...
Hope this helps
============================================================================
=====
1.
http://www.bitbybit.dk/mysqlfaq/faq.html#ch7_13_0
http://www.bitbybit.dk/mysqlfaq/faq.html#ch14_1_0
============================================================================
====
2.
Hi Barry,
I do not know what do you use for feeding your database, but in Perl you
shoud use the DBI module, and insert the binary data through bindings.
use DBI;
use strict;
...
my $dbh = DBI->connect("dbi:mysql:image_db", "user", "password") || die
"$DBI::errstr\n"; # connect to the database
...
my $sth = $dbh->prepare("INSERT jpeg_table SET size_x = $size_x, size_y
=$size_y, image_data = ?;") || die "$DBI::errstr\n"; # prepare the insert
statement, replacing the image data with a question mark
$sth->bind_param(1, $image_data); # binding the binary
data
$sth->execute() || die "$DBI::errstr\n"; # executing the
insert
...
$dbh->disconnect(); # disconnect
Regards,
Peter Szekszardi
============================================================================
3.
-----Original Message-----
From: Didi [mailto:[EMAIL PROTECTED]]
Sent: 21 February 2001 10:35
To: [EMAIL PROTECTED]
Subject: Save image to database
Dear all,
Can images be saved in an mysql database as a BLOB?
If so, how can I write the code in sql to add an image to a mysql database
record, and then subsequently view image in a browser via perl programming ?
--- Thank you ---
---------------------------------------------------------------------
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