★ wanayoo — archive 1999 http://www.phpbuilder.com/columns/florian19991014.php3Nouvelle recherche | Portail wanayoo
 
   


Search:

Keywords:

[ Register New Account ]

[ Logout ]   [ Login ]

Linux @ internet.com
Linux Today
Linux Planet
Linux Start
Just Linux
Linuxnewbie.org
Linux Apps
Linux Central
Linux Programming
BSD Today
SITE DESCRIPTIONS

 

Binary Data + MySQL + PHP

Or: How to store images directly in the sql database

Florian Dittmer

Florian Dittmer

If you want to store binary data like images and html files directly in your MySQL database, this column is for you!

I will show how you can store the data via the HTML forms "File" feature in your database and how you can access and use this data in your webproject.

If you have read the article "PHP, MySQL and images" by William Samplonius here on phpbuilder.com, this might be interesting for you as William stores the binary data somewhere on your harddisk (using a shell command), instead of storing the image directly in the Sql-Database.

Overview:

  • Create a new database on your SQL Server
  • A sample php3 script you can use to store data in your database
  • A sample php3 script with which you can access the stored data

Create a new database on your SQL Server

First of all, you have to create a new database on your SQL server in which your script will store the binary data.

For my example I use the following structure. To create this database, you have to do the following steps:

  • login to the mysql monitor
  • enter the command "create database binary_data;"
  • enter the command "use binary_data;"
  • copy and paste the following intructions (the table structure) to the monitor
  • the database+table should be created

CREATE TABLE binary_data (
id INT(4) NOT NULL AUTO_INCREMENT PRIMARY KEY,
description CHAR(50),
bin_data LONGBLOB,
filename CHAR(50),
filesize CHAR(50),
filetype CHAR(50)
);

Next Page

 

Comments:
IE 4.x on Windows not interpreting Data?Zachery Bir05/18/00 15:14
Invalid MySql resourcesChuck G05/11/00 17:04
Displaying image with <img src Miguel05/11/00 00:29
Displaying image with <img src Miguel05/11/00 00:26
data typesSteven Holloway05/10/00 21:12
data typesSteven Holloway05/10/00 20:55
Won't upload file and store in tableBrian05/05/00 09:15
RE: File upload problems - SOLVEDMarcel05/04/00 02:28
RE: File upload problemsMarcel05/03/00 03:17
File upload problemsMarcel05/02/00 14:54
RE: Binary Data + MySQL + PHPRene Mischak04/27/00 05:34
Binary Data + MySQL + PHPRavi Pandit04/26/00 01:49
RE: Input file variable missingCass Surek04/24/00 22:59
RE: performance considerationsCass Surek04/24/00 22:54
addslashes - the data isn´t being storedCass Surek04/24/00 22:49
How can I generate a gif file using PHP?emouse04/23/00 18:11
performance considerationsCaspar von Seckendorff04/22/00 11:00
RE: database connectionRichard04/20/00 21:21
RE: ppgsql backupAxel son of Jack04/20/00 19:36
RE: ppgsql backupAxel son of Jack04/20/00 19:28
database connectionShirley04/19/00 08:30
RE: "getdata.php3?=2" doesn't work...Baran Bingol04/19/00 05:10
RE: POST not allowRaymond04/16/00 05:11
POST not allowRaymond04/16/00 05:04
i got itRudy Setiawan04/16/00 04:44
Cant get it to work at all ... pls help meRudy Setiawan04/16/00 04:36
Width and HeightMatt Whitted04/15/00 19:41
getdata.php3 works but....Sergio04/14/00 19:03
NO OUTPUT !!!!markus04/14/00 04:24
Input file variable missingMark Wolfgramme04/13/00 09:22
Input file variable missingMark Wolfgramme04/13/00 09:22
Blank screenRobbie04/13/00 08:44
ppgsql backupRuben04/12/00 12:12
How do I List Active sessions on my webserverFredrik04/12/00 00:55
RE: how to use mysql_insert_id??Dan Nedoborski04/11/00 18:29
RE: "getdata.php3?=2" doesn't work...Hennie Jansen04/11/00 11:08
how to use mysql_insert_id??thinker04/10/00 20:01
File Progress IndicatorDan Nedoborski04/10/00 17:36
RE: How to display Flash File stored in Database?Scott Helms04/06/00 17:48
Got error: fopen("...") - Permission dieniedRein Velt04/06/00 04:56
"getdata.php3?=2" doesn't work...Jakub Gaj04/06/00 04:47
HELP ME!Morten04/03/00 13:34
RE: Can't find the imageRainer Collet03/31/00 10:05
RE: Can't find the imageRainer Collet03/31/00 10:05
RE: How to store image to PostgresBruno Rothgiesser03/30/00 14:21
How to display Flash File stored in Database?Ivan Christiansen03/29/00 13:30
Can't find imageRAMac03/26/00 23:22
Can't upload files bigger than 1 MBPer Øyvind Moeng03/23/00 09:51
I can't get mine to do anythingMichael03/23/00 01:23
RE: How to send file name?Rey Mangahas03/22/00 19:03
How do I dump the database with an imageJamie Becker03/22/00 13:12
how deal the attached file in email with php3Yang Qianggen03/22/00 10:56
RE: How to send file name?Ben Schumacher03/22/00 01:05
How to store image to PostgresDusan Halamka03/21/00 07:15
RE: Sending FilenameDan Holtz03/20/00 10:00
RE: Sending FilenameDan Holtz03/20/00 10:00
RE: got error from uploading some fileIan....03/19/00 00:31
RE: How to send file name?Greg Speed03/17/00 16:39
RE: How to send file name?Jason Mitchell03/17/00 02:36
How to send file name?Andrea03/16/00 16:52
undefines errorMarkus03/16/00 08:45
got error from uploading some fileWilson03/16/00 06:03
RE: UploadSander Boulogne03/15/00 05:49
RE: UploadPeter Martha03/14/00 17:13
RE: Upload .. same problem hereSander Boulogne03/14/00 16:42
URL passingRuben03/14/00 01:56
RE: Uploadpierre03/13/00 18:59
RE: UploadBent Karlsen03/13/00 16:50
UploadBent Karlsen03/12/00 15:52
php&DB2Riad Abd El Magid03/10/00 07:39
RE: Can't find the imageJake Goena03/10/00 01:34
Can not upload file bigger than 2MMike, H03/09/00 23:19
File uploading problemLiam Gretton03/09/00 11:40
RE: Why? and how to searchFrederik JOLY03/08/00 03:13
$form_data variablesAragon Gouveia03/07/00 17:22
RE: Why?Steve Grevemeyer03/04/00 18:49
RE: Why?Chester Bullock03/04/00 12:24
RE: Why?Rob Sletten03/03/00 14:52
RE: Why?Tim Perdue, PHPBuilder.com03/03/00 12:21
RE: Why?Chester03/03/00 10:03
RE: Why?Chester03/02/00 14:37
Why?Scott Genevish03/02/00 13:48
RE: Can't find the imageChester03/02/00 10:23
RE: Can't find the imageRobert Bergs03/02/00 03:42
Form EncodingRobert Bergs03/02/00 03:40
Can't find the imageChester02/29/00 14:40
the output part of the scriptalexander02/28/00 06:02
 

Add A Comment:

Not [Logged In]

Subject:

Message:

Due to abuse, you must now be [ logged in ] to post



 

Sample Code Library | Columns | Mail Archive | Support Forums | Get Started! | Links | Contribute!

Contact (non support questions)

internet.com
Internet News, Internet Stocks/VC, Internet Technology, Windows Internet Tech., Linux/Open Source, Web Developer, E-Commerce/Marketing, ISP Resources, Downloads, Internet Resources, Internet Lists, International
Search internet.com, Advertising Info, Corporate Info, Internet Trade Shows

internet.commerce
Be a Commerce Partner, Software Store, Computer Help, Register Domains, Internet Jobs, Map Your Website, Rent E-mail Lists, Bookstore, Press Release dist., Internet Research, Venture Capital, Web Publishing, Build Your Intranet, Ask an Expert, Get e-Biz Intell., Content for Websites, Income for Small Biz, Address Verification, Build Sticky eStores, Advertise a Coupon, Promotional Products, Accept Credit Cards, Download Solutions, Create a Web Store, fax & vmail for free, Hardware Store, Track Time & Expenses, News to Your Desktop, Small Biz Purchasing, B2B Directory/Search, Freelancers

Copyright 2000 internet.com Corp. All Rights Reserved. Legal Notices, Reprints.   Privacy Policy

http://www.internet.com/