Jump to content

Photo doesn't display


jpergega

Recommended Posts

Hi

 

I am trying to fetch photos from the database but it doesn't show on the website page:

 

PHP -

 

function getImage(){
$query = "SELECT * FROM imgLib WHERE id=$_SESSION['id']";
$result = mysqli_query($con, $query);
while($row = mysqli_fetch_assoc($result)){
echo $row['img'];
}
}
HTML -
<img class="img-responsive" src="<?php getImage(); ?>" >
Result on Website page -
see attachment
Thanks

post-171792-0-51366100-1423396297_thumb.png

Link to comment
Share on other sites

Have you checked the source code of the page to see what is actually in the src attribute?

 

I assume either an error message, an empty string or multiple filenames.

Link to comment
Share on other sites

It sounds like PHP isn't being executed.

 

At least two conditions need to be met for PHP to work:

  1. It's running on a server that can execute PHP
  2. The file has a .php extension, not .html.

Link to comment
Share on other sites

Thanks for this

 

I am using WAMP Server

I changed my files' extension to .php and is now giving me error message inside the image frame says: call to undefined function functionName()

 

Here is how I call the function :

<img class="img-responsive" src="<?php include 'functions.php'; getImage(); ?>" >

Edited by jpergega
Link to comment
Share on other sites

have u included functions.php at the beginning of the page? if u haven't, I think, removing the functions.php from img tag and placing it at the beginning of the page can solve the problem. u doesn't need to include inside img tag.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...