views:

101

answers:

2

I am creating a website, and have a tabbed horizontal menu. In order to cut back on the number of files I have to edit when I have to make changes to the menu I want to put the navigation in a separate file that I can call using a PHP include statement. When I do this, however, the nav disappears entirely from the page. The rest of the content remains, and there are no error messages. I have been looking for answers for this for weeks, and have tried every version of the PHP include statement that I could find. None of them worked. This was the last attempt. I have the file "nav.php" in a folder named "includes" in a main dir called "testsite" I use Windows XP, use NotePad++ as my text editor, and have been testing in Firefox. I can't find an answer anywhere - any help would be appreciated.

Lorianna

A: 

It seems like that the PHP isn't being parsed, have you tried viewing the source of the page in the browser? Try to see if your PHP command shows up in there as it is. What is the extension of your main page that you are calling in the browser? Are you using it like http://localhost/abc.php ? What web server are you using?

Sabeen Malik
A: 

I'm boldly presuming that errors are disabled or suppressed by your PHP installation. I would advise turning them on.

Local Server

If your installation is on your local machine, you can edit the php.ini file and adjust the following lines:

error_reporting  =  E_ALL|E_STRICT
; or
error_reporting  =  E_ALL
display_errors = On

Do not put spaces around the vertical pipe | between E_ALL and E_STRICT or PHP will parse the line improperly and disable errors. Be sure to restart Apache in order to propagate any changes in php.ini.

Remote Server

If you are running your script on a remote server and cannot change the ini file directly, you may be able to enable error reporting at runtime by adding the following to the top of your script (before any includes):

error_reporting(-1);

Unfortunately, fatal errors (mismatched brackets, etc.) cannot be detected with the runtime switch because the script does not compile. As the rest of your page displays, though, the runtime error switch will catch a missing include().

Further Reading

banzaimonkey