jpergega Posted February 8, 2015 Share Posted February 8, 2015 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 Link to comment Share on other sites More sharing options...
Ingolme Posted February 8, 2015 Share Posted February 8, 2015 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 More sharing options...
jpergega Posted February 8, 2015 Author Share Posted February 8, 2015 I only can see this error message : Failed to load resource: the server responded with a status of 403 (Forbidden) Link to comment Share on other sites More sharing options...
Ingolme Posted February 8, 2015 Share Posted February 8, 2015 That sounds like a message in the console. I was asking about the HTML. If you right click and select "View source" what does the <img> tag look like? Link to comment Share on other sites More sharing options...
jpergega Posted February 8, 2015 Author Share Posted February 8, 2015 Sorry this is what I got: <a class="thumbnail" href="#"> <img class="img-responsive" src="<?php getImage(); ?>" > </a> Link to comment Share on other sites More sharing options...
Ingolme Posted February 8, 2015 Share Posted February 8, 2015 It sounds like PHP isn't being executed. At least two conditions need to be met for PHP to work: It's running on a server that can execute PHP The file has a .php extension, not .html. Link to comment Share on other sites More sharing options...
jpergega Posted February 8, 2015 Author Share Posted February 8, 2015 (edited) 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 February 8, 2015 by jpergega Link to comment Share on other sites More sharing options...
Ingolme Posted February 8, 2015 Share Posted February 8, 2015 I don't think I've seen all your code. Does the error message specifically say "functionName()" or does it say "getImage()"? Link to comment Share on other sites More sharing options...
jpergega Posted February 8, 2015 Author Share Posted February 8, 2015 It says getImage() Link to comment Share on other sites More sharing options...
funbinod Posted February 8, 2015 Share Posted February 8, 2015 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now