emvy03 Posted June 27, 2011 Share Posted June 27, 2011 Hi guys, I'm building a website in php and am trying to 'include' a php page into the main index file. However, the problem I have is that while images display fine in the standalone php file, when I 'include' this in my index file the images wont display. Instead I get the broken link symbol. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/240561-php-not-displaying-images/ Share on other sites More sharing options...
Maq Posted June 27, 2011 Share Posted June 27, 2011 Most likely a path issue. Post the image path dir, where the php file resides, and your include code. Quote Link to comment https://forums.phpfreaks.com/topic/240561-php-not-displaying-images/#findComment-1235660 Share on other sites More sharing options...
cyberRobot Posted June 28, 2011 Share Posted June 28, 2011 If you have a directory structure that looks like this: homeimagesnavimg1.jpg navimg2.jpg [*]includes main_navigation.html [*]index.php Keep in mind that the image path for main_navigation.html when it's included in index.php does not start in the includes folder. Instead it starts in the home folder since that's where index.php is located. To avoid this type of issue, use root-relative links in the main_navigation.html file. So instead of: <img src="../images/navimg1.jpg"> You could use: <img src="/images/navimg1.jpg"> Quote Link to comment https://forums.phpfreaks.com/topic/240561-php-not-displaying-images/#findComment-1235841 Share on other sites More sharing options...
emvy03 Posted June 29, 2011 Author Share Posted June 29, 2011 Hi, Thanks alot for your replies! I was being a total prat, it was a path issue; I missed a '/' at the start of the code. Cheers for pointing it out. Quote Link to comment https://forums.phpfreaks.com/topic/240561-php-not-displaying-images/#findComment-1236219 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.