Reply to trying to display image from mysql database

Your name:

Reply:


Posted by eholz1 on 12/09/06 05:53

Hello Group,

Perhaps you can help me. I have a mysql db, that holds images.
Images are encoded using base64_decode/encode, etc. Image data seems
fine.
I have a view.php page that is supposed to show the image, and an
image.php page that accesses
the database, retrives the image data, and then (theoretically) prints
the decoded data to the page.
below is the view.php page code: problem area the img tag src no
worky.

What am i missing (having stolen the idea for this from the web!!!!
thanks,
eric
/*******************************************************************/
<html>
<head>
<title>Get The Image</title>
<link rel="stylesheet" type="text/css" href="css/csssmall.css" />
</head>
<body>
<center><img src="testimage/Sunset.jpg" width="300" border="1"
alt="Image of Sunset"></center>
<p class="para-color"><?php echo 'Beautiful Image' ?></p>
<br>
<center><img src="image.php?img=3" width="200" border="1" alt="Image of
Thelma Todd"></center>
<p class="para-color"><?php echo '\'Nother Beautiful Image' ?></p>
</body>
</html>
/******************************************************************/

below is the image.php code:
/**********************************************************************
<?php
$dbhost = 'localhost';
$dbuser = 'auser';
$dbpass = 'apassword';
$dbcnx = @mysql_connect($dbhost,$dbuser,$dbpass);

if (!$dbcnx)
{
echo( "connection to database server failed!");
exit();
}
if (! @mysql_select_db("portfolio") )
{
echo( "Image Database Not Available!" );
exit();
}
?>
<?php
$img = $_REQUEST["img"];
?>

<?php
$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["sixfourdata"];
$title = $row['title'];
}
?>
<?php
//echo $encodeddata;print??
echo base64_decode($encodeddata);
//echo $prefix . $encodeddata;
?>
/*************************************************************************

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация