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\wwwrootooter.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\wwwrootooter.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>

rn10950
  • 93
  • 3
  • 11

3 Answers3

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"); ?>
jszobody
  • 28,495
  • 6
  • 61
  • 72
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>
John Conde
  • 217,595
  • 99
  • 455
  • 496
  • 5
    Or use forward slashes `/`, which (surprisingly) works just as well on Windows. – Halcyon Jan 03 '14 at 00:49
  • The PHP engine will convert path seperators automatically so you are safe to use / even when on non-windows based platforms. – Rottingham Jan 03 '14 at 00:51
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

Anat0m
  • 37
  • 6