Hi All:
I have the following script it works on puitting the image into and retrieving the image from the database it just does not show the pic.
The database table 'images' has two fields id and image. I lifted most of this code from a bulletin board. I have narrowed it down to the line in red. It seems to not be calling the secondtype.php3 file. I had a couple of echo statments that are not being displayed. secondtype.php3 is in the same directory as the index file. Any help on this would be greatly appreciated.
Best
Kenn Ward
<?php
require "login.php"
?>
<?php
$Picture = "my_graphic.gif";
If($Picture != "none") {
$PSize = filesize($Picture);
$handle = fopen($Picture, "r");
$mysqlPicture = addslashes(fread($handle, $PSize));
mysql_connect($host,$username,$password) or die("Unable to connect to SQL server");
@mysql_select_db($db) or die("Unable to select database");
mysql_query("INSERT INTO images (image) VALUES ('$mysqlPicture')") or die("Can't Perform Query insert");
}
else {
echo"You did not upload any picture";
}
?>
<HTML>
<head>
<title>database graphic read test</title>
</head>
<BODY>
<?
mysql_connect($host,$username,$password) or die("Unable to connect to SQL server");
@mysql_select_db($db) or die("Unable to select database");
$result=mysql_query("SELECT * FROM images") or die("Can't Perform Query select");
While($row=mysql_fetch_object($result)) {
echo "<IMG SRC=secondtype.php3?PicNum=$row->id>";
// echo "<IMG SRC=$Picture>"; // this line will display the file pefectly
}
?>
</BODY>
</HTML>
secondtype.php3
<?
mysql_connect($host,$username,$password) or die("Unable to connect to SQL server");
@mysql_select_db($db) or die("Unable to select database");
$result=mysql_query("SELECT * FROM images WHERE id=$PicNum") or die("Can't perform Query");
$row=mysql_fetch_object($result);
Header( "Content-type: image/gif");
?>