cant view image from database

From: Date: Thu, 12 Feb 2015 17:30:24 +0000
Subject: cant view image from database
Groups: php.general 
Request: Send a blank email to php-general+get-324436@lists.php.net to get a copy of this message
Hi, I can't view my image from mysql database. I used curl to download the image to mysql database, and im trying to view the image, im getting error from firefox debugger. Here is my code for downloading the image <?php $servername = "localhost"; $username = "recorduser"; $password = "password123"; $database = "record"; // Create connection $conn = mysqli_connect($servername, $username, $password, $database); // Check connection if (!$conn) { die("Connection failed: " . mysqli_connect_error()); } $ch = curl_init ("http://www.albaldnews.com/upimages/news/thumb_albald11-04-2014-993734.jpg" ); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_BINARYTRANSFER,1); $rawdata=curl_exec ($ch); curl_close ($ch); $rawdata = addslashes($rawdata); $sql = "INSERT INTO picture (image)VALUES ('$rawdata')"; $result = mysqli_query($conn, $sql); ?> And the code for viewing the image as flow; <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>dispaly image</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> </head> <body> <?php #header("Content-type: image/jpeg"); $servername = "localhost"; $username = "recorduser"; $password = "password123"; $database = "record"; // Create connection $conn = mysqli_connect($servername, $username, $password, $database); // Check connection if (!$conn) { die("Connection failed: " . mysqli_connect_error()); } $sql = "SELECT * FROM picture"; $result = mysqli_query($conn, $sql); header("Content-type: image/jpeg"); $row = mysqli_fetch_array($result); $img = $row["image"]; echo '<img src="'.$img.'" />'; ?> Firefox error code: <img src="http://192.168.206.129/rssfeed/showimage.php" alt="The image "http://192.168.206.129/rssfeed/showimage.php" cannot be displayed because it contain

« previous php.general (#324436) next »