SORRY, bad couple of nights coding. Forgot the correct syntax.
MODS please feel free to delete or leave as an example. Don't mind either way.
I know this should not be done and it should be done using the path to the filename. I am just experimenting with both ideas to see the overhead and reduce programming time as I am creating pages on the fly.
I cannot get the image to output.
Using MYSQL SERVER 5.0 and PHP 5.2.6
The Code from the two files involved is
MEMORIAL.PHP
<?php
$rat_num = $_GET['id'];
// Include our login information
include('db_login.php');
// Connect
$connection = mysql_connect($db_host, $db_username, $db_password);
if (!$connection){
die ("Could not connect to the database: <br />". mysql_error( ));
}
// Select the database
$db_select=mysql_select_db($db_database);
if (!$db_select) {
die ("Could not select the database: <br />". mysql_error( ));
}
// assign the query
$query = "SELECT * FROM in_memorial WHERE record_num = '{$rat_num}'";
// Execute the query
$result = mysql_query( $query );
if (!$result){
die ("Could not query the database: In_Memorial<br />". mysql_error( ));
}
// $row = mysql_fetch_row($query);
while($row = mysql_fetch_row($result)) {
echo('<h1>'.$row[1].'</h1>');
echo ('<img src="'.$row[7].'" alt="generated from file path"><br>');
echo ('<img src="image2.php?id='.$rat_num.'" alt="generated from image2.php"><br>');
}
?>
IMAGE2.PHP
<?php
include('../memorial_wall/db_login.php');
mysql_connect($db_host, $db_username, $db_password) or die("Can not connect to database: ".mysql_error());
mysql_select_db($db_database) or die("Can not select the database: ".mysql_error());
$id = $_GET['rat_num'];
if(!isset($id) || empty($id)){
die("Please select your image!");
}
else{
// $query = mysql_query("SELECT * FROM in_memorial WHERE record_num='.$id.'"); TOTALLY WRONG.....
$query = mysql_query("SELECT * FROM in_memorial WHERE record_num='{$id}'"); CORRECT
$image = mysql_fetch_array($query);
$content = $image[1];
header('Content-type: image/jpeg');
echo $content;
exit();
}
?>
By running the procedures through the browser I get
Heading OK
Picture from file path OK
Picture from BLOB - fails with ALT displayed.
Check it out here
http://www.prrr.org/memorial_wall/
Click on 1st picture (SQUIRT)
If I check using http://www.prrr/org/memorial_wall/image2.php?rat_num=1
I get the following error
http://www.prrr.org/memorial_wall/image2.php?rat_num=1
Anyone got any ideas?
Thanks
Q