dartketamin Posted June 28, 2012 Share Posted June 28, 2012 Hi guys i wonder if anyone can help me here my homepage (index.php) includes 2 files: <?php include('header.php'); include('menu.php'); ?> this works just fine it displays all the images on both header and menu as there all in the same directory the problem im having is when i try to include these files to my message board index.php file in /messageboard directory none of the images display is there any way round this? Quote Link to comment https://forums.phpfreaks.com/topic/264927-php-include-help/ Share on other sites More sharing options...
PravinS Posted June 28, 2012 Share Posted June 28, 2012 try.. <?php include('../header.php'); include('../menu.php'); ?> Quote Link to comment https://forums.phpfreaks.com/topic/264927-php-include-help/#findComment-1357662 Share on other sites More sharing options...
dartketamin Posted June 28, 2012 Author Share Posted June 28, 2012 Hi thanks for the fast replay. <?php include('../header.php'); include('../menu.php'); ?> That works but my problem is its not loading any of the images in them files as the paths are wrong id have to add ../ to every single image for it to work and that is not an option as lots of other files are using the menu.php Quote Link to comment https://forums.phpfreaks.com/topic/264927-php-include-help/#findComment-1357667 Share on other sites More sharing options...
memfiss Posted June 28, 2012 Share Posted June 28, 2012 u should define in each main file dir constants #index.php define('IMGDIR' , 'images'); #messageboard define('IMGDIR' , '../images'); #then u can use it in include file $img = IMGDIR . '/someimg.jpg'; Quote Link to comment https://forums.phpfreaks.com/topic/264927-php-include-help/#findComment-1357684 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.