I just can't get this basic PHP include to work.....

I’m at a loss…
I think there must be something that I’m skipping over, but I can’t seem to figure out a simple PHP include. I am relatively new to coding, but still…really??

What I’m doing:

-Trying to include a basic nav code into my index.html page

-I’m saving the nav code (without any beginning or ending tags) as nav.php in the “includes” directory (one step up from index.html)

-Trying to include the file in index.html with : <?php include("includes/nav.php"); ?>

-Yet it DOESN’T work…

I have tried modifying the syntax, and have tried every possibility (I think). I’ve tried removing the “php” after the opening tag “<?”, I’ve tried removing the “(” “)” from the file and replaced with ’ ', but I haven’t gotten it to work.

Is there a possibility that my server doesn’t allow it?? I have InMotion Hosting, and haven’t had a single issue with they yet.

ANY suggestions would be great…

naming a file .html will cause the line <?php blah blah blah ?> to be ignored as the php parser is not processing the page. Rename your file index.php and the include statement will work fine.

to call a file in a directory above the public folder try this:
[php]<?php include("../includes/nav.php"); ?>[/php]
or
[php]<?php include($_SERVER['DOCUMENT_ROOT'] . "../includes/nav.php"); ?>[/php]

:wink:

Sponsor our Newsletter | Privacy Policy | Terms of Service