A blob is a nice field to use I guess

see these attachements from when I asked the same Q...

Some of them may or maynot be helpful..

regards
Barry

-----Original Message-----
From: Danie Weideman [mailto:[EMAIL PROTECTED]]
Sent: 23 February 2001 02:02
To: [EMAIL PROTECTED]
Subject: Saving pictures in MySql


Hi everyone

I am new to MySql and PHP

I have downloaded and configured both

I have just finished my first db and are on a high. I was quickly broad to
ground when I tried to load a image via a form into the database. Could
someone
please help with:

What field type must be defined for pictures.
How to load and retreive pictures from a database using PHP 

Any thing more will be appreciated

Kind Regards
Danie Weideman

---------------------------------------------------------------------
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



> hi I am pretty new at this and would like to know how does one store a
> binary blob to the mysql DB ie I would like to store a jpeg to the db

http://www.bitbybit.dk/mysqlfaq/faq.html#ch7_13_0

http://www.bitbybit.dk/mysqlfaq/faq.html#ch14_1_0

/ Carsten
--
Carsten H. Pedersen
keeper and maintainer of the bitbybit.dk MySQL FAQ
http://www.bitbybit.dk/mysqlfaq





If your using PHP there is an article here on doing it with PHP3, it works
on 4 as well.  HTH

http://www.phpbuilder.com/columns/florian19991014.php3

Dave W.

 -----Original Message-----
From:   Barry Radloff [mailto:[EMAIL PROTECTED]] 
Sent:   Tuesday, January 30, 2001 10:56 PM
To:     '[EMAIL PROTECTED]'
Subject:        Binary data



hi I am pretty new at this and would like to know how does one store a
binary blob to the mysql DB ie I would like to store a jpeg to the db

Thanks

Barry Radloff
R&D
Media24

---------------------------------------------------------------------
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




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
PortoLogic Ltd.
Portal building, design, net survey and more...

On Wed, 31 Jan 2001, Barry Radloff wrote:

> 
> 
> hi I am pretty new at this and would like to know how does one store a
> binary blob to the mysql DB ie I would like to store a jpeg to the db
> 
> Thanks
> 
> Barry Radloff
> R&D
> Media24
> 





Hi okie heres a snippet of my php code:
the code below takes a file uploaded from the web with $file as declared
filename on
the form.

if ($file_size>0) { //check whether the file is not empty
$data = addslashes(fread(fopen($file, "r"), filesize($file)));  //read the
file and
add neccessary quotes
$SQL="Insert into Files (Filename,Filetype,Filesize,data) values
('$file_name','$file_type','$file_size','$data')"; //SQL commands to insert
into table
named 'FILES'
$result = mysql_query ($SQL)
        or die ("ERROR Uploading File:".mysql_errno().":
".mysql_error()."<BR>$SQL");
}

okie hope that helps!

Teddy

"Robert C. Paulsen Jr." wrote:

> On Sat, Feb 03, 2001 at 10:20:07PM +0800, Teddy A Jasin wrote:
> > I have the scripts in php to do this if u want.
>
> Yes, that would help! thanks.
>
> >
> > "Robert C. Paulsen Jr." wrote:
> >
> > > How can I put binary data into a MySQL database?
> > >
> > > I assume the data type is blob, but I don't see how I can
> > > use SQL syntax to insert anything but text data. I would
> > > like to include various binary files (tar files, zip files,
> > > image files, etc.).
> > >
>
> --
> ____________________________________________________________________
> Robert Paulsen                                     [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



---------------------------------------------------------------------
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