Jump to content

Recommended Posts

<? 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?

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-

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.

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.