Php inlcude path problem (I think)

software development

#1

I am trying to use php include to add header, footer, and navigation to my site.

I used this code:

but I got this when I tried to load my page:

I am thinking that it just doesn’t know where to find my files. I tried having them in the same directory, and specifying the directory with a full path, but the error message remains the same.

I don’t know what the “.sada” is, but since it is above the level of my sites’s directory, I’m guessing that the include function is looking for my files too high in the structure.

How am I to correctly specify my include files, which I want to house in a directory named “includes”?

What have I done wrong?


#2

You have a syntax error (a semicolon is in the wrong place), but there is an easier way to do it anyway. Assuming that your “includes” folder is your web root (ellenseyes.com/includes), use this code:

<?php include($_SERVER['DOCUMENT_ROOT']."/includes/main-nav.php"); ?>You can put that on any page of your site, in any directory, and it will always work.


si-blog | Keystone Websites
Save $97 on yearly plans with promo code [color=#CC0000]SCJESSEY97[/color]


#3

Thank you scjessey

I had already corrected the syntax error.

That works exactly as it should.


#4

Obviously you do not consistently spell “inlcude” correctly. :wink:

----------
[color=#00CC00]ANONYMOUS0 => Max Discount[/color], [color=#6600CC]ANONYMOUS2 => Max Discount less $1[/color] or Cut the code, [color=#CC0000]it’s their birthday:[/color] [color=#00CC00]9999 => $99.99 Off[/color]


#5

Obviously you do not consistently construct sentences correctly. :slight_smile:


si-blog | Keystone Websites
Save $97 on yearly plans with promo code [color=#CC0000]SCJESSEY97[/color]


#6

Geez! You have no idea how long it took me to find the typo. I looked through the entire thread …