Click here to Skip to main content
15,890,512 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Below is the home.php page that is supposed to display the images along with the imageID that are in the database. The actual images are in a folder called "user_images" and only the name and file path is stored in the database.

When I try to display them, the imageID is retrieved but the immage is not ,only broken image icons appear on the screen


prepare("SELECT * FROM images ORDER BY imageID
DESC");

$stmt->execute();

}
catch(PDOException $e)
{

$e->getMessage();
}

?>





rowCount() > 0)
{
while($row=$stmt->fetch(PDO::FETCH_ASSOC))
{
extract($row);
?>





What I have tried:

I have tried to add header("Content-type: image/jpg"); to the code but that just displays a small square at the top left hand side of the page

What am I doing wrong?
Posted
Updated 5-Dec-16 2:48am

1 solution

It looks like you're opening the table to retrieve the image file names. What it does not look like is that you're trying to actually display the images themselves.
PHP
<!--?php<!-- newline ---->ECHO "<img src="{$row[0]}">";  
?>


Note that path's for these can be very finicky, as well. Are you making sure your results have the correct path relative to you code page?


At least from the little bits you used in formulating your question.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900