views:

91

answers:

4

Hi everybody, this isn't a problem as such but it's bugging me and I would appreciate any help. It might be totally obvious but I can't see it.

$root_path = $_SERVER['DOCUMENT_ROOT']

require($root_path .'template/header.php')

require($root_path .'template/footer.php')

The script will include one or the other but not both. It will run and include the header but not the footer, if I swap them round it will load the footer first but not the header.

I've tried using include instead of require but get the same result.

It gives the error allow_url_include = 0. I know turning this on will solve it but my question is why is it happening? Why will it include one file but not the other? Is there any way to get them to both run without turning allow_url_include on (I'm trying to be security conscious). I have PHP 5.3 and am running WAMP. Thanks in advance for your help!

A: 

Looks like you're redefining $root_path in the included file.

soulmerge
A: 

Maybe $root_path is changed in the file header.php or footer.php ?

powtac
A: 

There isn't anything wrong with what you've written. As the others have said, something is happening to $root_path or the script is terminating before it gets to that include.

Do a var_dump($root_path) right above the footer include. If that fires, you know it's getting to the include. If it still isn't working, do some echoes from within your footer to see if it gets inside the file.

ryeguy
A: 

Thanks for your help everybody, I appreciate it. I was redefining $root_path in the header file, I feel so silly. I completley missed it!

Colin
Welcome to stack overflow! Make sure you upvote and accept someone's answer. Also, since this site is in a Q/A form, you don't really answer your own question, and any discussion you need should be in the comments of an answer or via an edit of your question.
ryeguy