> -----Original Message----- > From: Stuart Dallas [mailto:stuart@xxxxxxxx] > Sent: Thursday, February 12, 2015 9:45 PM > To: Bastien Koert > Cc: hadi; php-general@xxxxxxxxxxxxx > Subject: Re: cant view image from database > > On Thursday, Feb 12, 2015 at 6:22 pm, Bastien Koert <phpster@xxxxxxxxx>, > wrote: > You're echoing out an image tag, you just need to echo out the image > > > header("Content-type: image/jpeg"); > > $row = mysqli_fetch_array($result); > > $img = $row["image"]; > > echo $img; > > > > > > And at the very least you need to be using mysqli_real_escape_string, and > not addslashes! I tried your code but not helping im still getting error from firefox 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 contains errors> also I used mysqli_real_escape_string. But not helping. > > 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 > > > > > > > > > -- > > > PHP General Mailing List (http://www.php.net/) > > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php