Displaying BLOB from Database - Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more
Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more
Go Back   Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more > Webmaster Tech > Databases - MySQL, SQL, Oracle, Access and others

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 07-18-2011, 03:32 PM   #1 (permalink)
Junior Member
 
Join Date: Jul 2011
Posts: 1
Default Displaying BLOB from Database

Hello I am new to this forum and would greatly appreciate any help. I am trying to display a BLOB from my database onto a webpage, but I have no clue how to do this. My current code displays the name of the BLOB, not the BLOB itself. Here is the code:

<html>

<?php
$con = mysql_connect("mysql17.000webhost.com","a2870045_r ayman3","hawaii" );

mysql_select_db("a2870045_picture", $con);

$result = mysql_query("SELECT * FROM Art ORDER BY RAND() LIMIT 1");

$row= mysql_fetch_array($result);

$file = $row["File"];
mysql_close($con);
?>
<center><?=$file?></center>
</html>

Again, any help would be appreciated. If you need clarification, please let me know.
rene.miller3 is offline   Reply With Quote
Sponsored Links
Old 09-16-2011, 04:18 PM   #2 (permalink)
Junior Member
 
Join Date: Sep 2011
Location: Long Islanf, NY, USA
Posts: 33
Default Re: Displaying BLOB from Database

You first have to write the data ($file, assuming that the data really is the graphic file, not just its name) to a file. Then include an <img> tag in your HTML that points to that file.

You could also use PHP's image processing library, but that would take a bit of studying.

Keeping graphics in a database is bad programming. Keep the file names in the database and keep the graphics in files on the hard drive. Then you just write the <img> link using the returned name:

echo '<img src="'.$file.'" />';
Rukbat is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Sponsors

» Links

» Affiliates
Web Hosting
Online Backup Reviews
Marketing Find
Merchant Select
SiteMap Builder
Host Compare

» Links

» Sports Network
Paintball Forum
Football Forum
Hockey Forum
Golf Forum
Boxing Forum
Lacrosse Forum
Baseball Forum
SnowBoarding Forum
Soccer Forum
MMA Forum


All times are GMT -4. The time now is 08:13 AM.


Powered by vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.2
Webmaster Forums
Web Hosting | Chicago Web Hosting | Web Hosting