Mesden Posted July 1, 2010 Share Posted July 1, 2010 <? include '/topbar.php' ?> What I did previously was create a seperate file on my server called topbar.php. This would contain the Links in the Navigation Bar at the top of the page so rather than having to update the links on every page with that navigation bar, I could just use an include and change them all at once. Well now that I upgraded to PHP5, that include command doesn't seem to work anymore. Any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/206344-basic-php-includes-arent-working-in-php5/ Share on other sites More sharing options...
mrMarcus Posted July 1, 2010 Share Posted July 1, 2010 Use full php tags: <?php include '/topbar.php' ?> Note the <?php instead of just <? Quote Link to comment https://forums.phpfreaks.com/topic/206344-basic-php-includes-arent-working-in-php5/#findComment-1079415 Share on other sites More sharing options...
Mesden Posted July 1, 2010 Author Share Posted July 1, 2010 Nope, still doesn't work. Quote Link to comment https://forums.phpfreaks.com/topic/206344-basic-php-includes-arent-working-in-php5/#findComment-1079443 Share on other sites More sharing options...
ChemicalBliss Posted July 1, 2010 Share Posted July 1, 2010 The forward slash ( / ) at the start if the file path denotes the ROOT of the current drive. eg, on a windows box, usually that is C:/topbar.php For the same directory as the script, you would use " ./ ", eg ./topbar.php For the directory before, you would use " ../ ", eg ../topbar.php -cb- Quote Link to comment https://forums.phpfreaks.com/topic/206344-basic-php-includes-arent-working-in-php5/#findComment-1079452 Share on other sites More sharing options...
PFMaBiSmAd Posted July 1, 2010 Share Posted July 1, 2010 Nope, still doesn't work. Define: doesn't work? That could mean a dozen different things, each with a different cause. At least tell us what symptom you see in front of you that makes you think it is not working. And are you debugging your code on a system with error_reporting set to E_ALL and display_errors set to ON in your master php.ini so that php would report and display all the errors it detects. You will save a TON of time. Quote Link to comment https://forums.phpfreaks.com/topic/206344-basic-php-includes-arent-working-in-php5/#findComment-1079459 Share on other sites More sharing options...
Mesden Posted July 1, 2010 Author Share Posted July 1, 2010 I mean the HTML that these includes link to aren't being shown at all. Quote Link to comment https://forums.phpfreaks.com/topic/206344-basic-php-includes-arent-working-in-php5/#findComment-1079466 Share on other sites More sharing options...
mrMarcus Posted July 1, 2010 Share Posted July 1, 2010 I mean the HTML that these includes link to aren't being shown at all. Pay attention to what ChemicalBliss was talking about. include() does not accept relative, HTML style paths to files. Instead, try something like this: include $_SERVER['DOCUMENT_ROOT'] .'topbar.php'; $_SERVER['DOCUMENT_ROOT'] will bring you to the root folder, usually 'public_html', so be sure to include any further directory structure to your include() to reach the file in question. Note that $_SERVER['DOCUMENT_ROOT'] ends with a / so do not add one immediately after. Give that a try. Quote Link to comment https://forums.phpfreaks.com/topic/206344-basic-php-includes-arent-working-in-php5/#findComment-1079531 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.