0

I want to retrieve the image from the database but its not work php code

<?php 
$DB_HOST = 'localhost';
$DB_USER = 'root';
$DB_PASSWORD = '';
$DB_DATABASE = 'capturemoment';

$con = mysql_connect($DB_HOST, $DB_USER, $DB_PASSWORD);
if(!$con) {
    die('Failed to connect to server: ' . mysql_error());
}

$db = mysql_select_db($DB_DATABASE);
if(!$db) {
    die("Unable to select database");
}
if(isset($_GET['id'])){
    $id= mysql_real_escape_string($_GET['id']);
    $query=mysql_query("SELECT * FROM 'artical' WHERE 'artical_id'=$id");
    while ($row =mysql_fetch_assoc($query))
    {
         $imageData=$row["articale_image"]; 
    }
    header("content-type: image/jpg");
    echo $imageData;
}
else {echo "Error!";}
?>

the php code that call the first code to view the image dynamic

<img src="image.php?id=1" alt="imge (Phottix Mitros Flash for Canon)" style="width:65%;height:100%; border:1px solid #E6E6E6; align:center;"></a>
mgaido
  • 2,987
  • 3
  • 17
  • 39
Arwaz2
  • 1
  • 1
    remove the quotes `FROM 'artical' WHERE 'artical_id'` - wrong identifiers. http://php.net/manual/en/function.mysql-error.php should have thrown you an error but you're not using that. Don't feel left out; 75% of the people who post these days, don't. – Funk Forty Niner May 05 '15 at 17:39
  • 1
    Please, [stop using `mysql_*` functions](http://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php). They are no longer maintained and are [officially deprecated](https://wiki.php.net/rfc/mysql_deprecation). Learn about [prepared statements](http://en.wikipedia.org/wiki/Prepared_statement) instead, and consider using [PDO](http://jayblanchard.net/demystifying_php_pdo.html). – Jay Blanchard May 05 '15 at 17:45
  • 1
    @JayBlanchard Problem solved I think *Sam*. Time we move on to cook us some bigger fish. MMmm, fish! Got any blackened gator on the grill tonight? – Funk Forty Niner May 05 '15 at 17:56
  • If you want it I can get it done @Fred-ii- *All seafood is good seafood Ralph* – Jay Blanchard May 05 '15 at 17:58
  • @JayBlanchard just fish and gator. "Seafood", not crazy about it, strangely enough. – Funk Forty Niner May 05 '15 at 17:59
  • *To each his own Ralph!* More oysters for me @Fred-ii-! – Jay Blanchard May 05 '15 at 18:02
  • I'll keep the pearls then @JayBlanchard – Funk Forty Niner May 05 '15 at 18:03

0 Answers0