0

I am using include to attach a navbar and a footer to pages on my site. The navbar works perfectly but the footer keeps giving me this error:

`Warning: include(C:\inetpub\wwwroot ooter.php) [function.include]: failed to open stream: Invalid argument in C:\Inetpub\wwwroot\templatewip.php on line 69

Warning: include() [function.include]: Failed opening 'C:\inetpub\wwwroot ooter.php' for inclusion (include_path='.;c:\php\includes;C:\Inetpub\wwwroot\') in C:\Inetpub\wwwroot\templatewip.php on line 69`

This is the code:

<div id="footer"> <?php include("C:\inetpub\wwwroot\footer.php"); ?> </div>

If it helps, here is the working code for the navbar:

<div class="navbar"> <?php include("C:\inetpub\wwwroot\menuembed.php"); ?> </div>

3 Answers 3

2

Anytime you use backslashes in a string you risk bumping into escape sequences.

See here for details: http://www.php.net/manual/en/regexp.reference.escape.php

Change your path to use forward slashes instead, and it will just work:

<?php include("C:/inetpub/wwwroot/footer.php"); ?>
Sign up to request clarification or add additional context in comments.

Comments

1

\f is the escape character for a form feed. So if you have \f in your string you need to escape the slash, too:

<div id="footer"> <?php include("C:\inetpub\wwwroot\\footer.php"); ?> </div>

2 Comments

Or use forward slashes /, which (surprisingly) works just as well on Windows.
The PHP engine will convert path seperators automatically so you are safe to use / even when on non-windows based platforms.
0

Include __DIR__.'footer.php'; if it is in your main dir, otherwise add path from your root dir to footer.php. For example my main folder is htpdocs and my footer is in inc folder then you write:

include __DIR__.'/inc/footer.php'; 

sorry for,mess writing from phone

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.