Re: displaying image from MySQL DB using HTML/PHP
- From: haydartuna@xxxxxxxxx ("Haydar Tuna")
- Date: Wed, 14 Mar 2007 08:41:40 +0200
Hello,
I think your image field in mysql table is BLOB. Firstly, you can
create like a image.php file for call image data from table. You can call
your image data this file with GET,POST or SESSION variables and in image
table there is a uqiue field for call any image such as personal id, id,
student number and so on and then you can call the image from your main
program. For example <img src="image.php?id=1453">.
--
Haydar TUNA
Republic Of Turkey - Ministry of National Education
Education Technology Department Ankara / TURKEY
Web: http://www.haydartuna.net
""Bruce Gilbert"" <webguync@xxxxxxxxx> wrote in message
news:463b785d0703131317q2747e35eu59bd4afd4f132041@xxxxxxxxxxxxxxxxx
I am having some difficulty getting an image to display on a php that.
I have added to MySQL DB.
Here is what I have tried so far....
in the MySQL DB I have a table called image_holder and the fields are
id,mimename,filecontents...filecontents field is set to a type of blob
using PHPMyAdmin and I have uploaded the image in MySQL.
In the PHP code I have:
[php]
<?php
$dbhost = 'hostaddress';
$dbuser = 'username';
$dbpass = 'password;
$dbcnx = @mysql_connect($dbhost,$dbuser,$dbpass);
if (!$dbcnx)
{
echo( "connection to database server failed!");
exit();
}
if (! @mysql_select_db("image_holder") )
{
echo( "Image Database Not Available!" );
exit();
}
$img = $_REQUEST["img"];
$result = @mysql_query("SELECT * FROM images WHERE id=" . $img . "");
if (!$result)
{
echo("Error performing query: " . mysql_error() . "");
exit();
}
while ( $row = @mysql_fetch_array($result) )
{
$imgid = $row["id"];
$encodeddata = $row["mimetype"];
$title = $row['filecontents'];
}
?>
and in the HTML code
<center><img src="image.php?img=1" width="200" border="1" alt=""></center>
I am probably way off base, so need some help!
--
::Bruce::
- References:
- displaying image from MySQL DB using HTML/PHP
- From: "Bruce Gilbert"
- displaying image from MySQL DB using HTML/PHP
- Prev by Date: Re: [PHP] displaying image from MySQL DB using HTML/PHP
- Next by Date: Re: [PHP] 2 errors I can not understand
- Previous by thread: Re: [PHP] displaying image from MySQL DB using HTML/PHP
- Next by thread: Re: [PHP] 2 errors I can not understand
- Index(es):
Relevant Pages
|