This is what i am having difficulty with. I know how to put an image into MySql. I know how to retrieve it. Problem is I cannot find how to put the information from the Image Column of MySql and move it in a session across pages. I don't want to always call a query and connect to the base to retrieve the image. I just want it to go into a Session after I have uploaded it into MySql once and use the retrieve code (below) on each page to display it.
Here the code so far.
Sending Image To Mysql
$image = addslashes(file_get_contents($_FILES['image']['tmp_name']));
$imagesize = getimagesize($_FILES['image']['tmp_name']);
if ($imagesize == FALSE)
{
echo "That's not an image";
}
else
{
$query = mysql_query("UPDATE table SET Image = '$image' WHERE ID = 1") or die(mysql_error());
}
Retrieve Code I have on a single page that I have retrieved from Mysql
$sql = "SELECT * FROM table WHERE ID = 1;
$result = mysql_query("$sql") or die("<b>Error:</b> Problem on Retrieving Image BLOB<br/>" . mysql_error());
$row = mysql_fetch_array($result);
echo '<img src="data:image/jpeg;base64,'.base64_encode( $row['Image'] ).'"/>';
Session Version (above) of what I am hoping for each page (Probably have the syntax wrong)
echo '<img src="data:image/jpeg;base64,'.base64_encode( $SESSION_$['row'][Image] )).'"/>';
The code I have used so far without success This code is after i have placed the image into mysql
$sql = "SELECT * FROM table WHERE id = 1";
$result = mysql_query("$sql") or die("<b>Error:</b> Problem on Retrieving Image BLOB<br/>" . mysql_error());
$row = mysql_fetch_array($result);
$_SESSION['row'][Image] = $row;
Somehow I don't think I can do this as it's an array still.
In summary : All I need is a code to retrieve the image from Mysql and put it into a session. Plus the code to put on each page (one line)
Cheers.