Hi,
I have written a php code to retrieve the image from the mysql database but I am getting the encrypted value. How to convert it into image and display it on the webpage.
Here is the code to retrieve:
$sql = "select photo1 from photos where id='1'";
$result = mysql_query($sql);
$values = mysql_fetch_array($result);
$db_img = $values['frnd_photo'];
$db_img = base64_decode($db_img);
$db_img = imagecreatefromstring($db_img);
echo "$db_img";
***f I print_r($db_img), it will display the encrypted value and echo "$db_img"; line will diplay Resource id #5 as the output
I have used this code to store image:
$handle = fopen("vid.gif", "rb");
$img = fread($handle, filesize('vid.gif'));
fclose($handle);
$img = base64_encode($img);
$sql = "insert into photos values(1,6,'nani',6,'$img')";
$result = mysql_query($sql);
Please help me to solve this issue. I am struggling with this from 2 days.
With regards