Hi All,

Please bare with me as I'm new to this forum and to web design. I was asked by my boss to design adn upload a new website via ftp, which I can do. I realised this morning that it is not as simple as just that! Basically, here's what I need help with..

When I access our URL this is what I get

Warning: include(includes/globals.php.inc) [function.include]: failed to open stream: No such file or directory in /home/planlond/public_html/index.php on line 5

Warning: include() [function.include]: Failed opening 'includes/globals.php.inc' for inclusion (include_path='.:/usr/lib/php') in /home/planlond/public_html/index.php on line 5

Warning: include(includes/functions.php) [function.include]: failed to open stream: No such file or directory in /home/planlond/public_html/index.php on line 6

Warning: include() [function.include]: Failed opening 'includes/functions.php' for inclusion (include_path='.:/usr/lib/php') in /home/planlond/public_html/index.php on line 6

Warning: include(lang/.php) [function.include]: failed to open stream: No such file or directory in /home/planlond/public_html/index.php on line 7

Warning: include() [function.include]: Failed opening 'lang/.php' for inclusion (include_path='.:/usr/lib/php') in /home/planlond/public_html/index.php on line 7

Warning: include(themes//config.php.inc) [function.include]: failed to open stream: No such file or directory in /home/planlond/public_html/index.php on line 8

Warning: include() [function.include]: Failed opening 'themes//config.php.inc' for inclusion (include_path='.:/usr/lib/php') in /home/planlond/public_html/index.php on line 8

Warning: include(themes//homepage.php) [function.include]: failed to open stream: No such file or directory in /home/planlond/public_html/index.php on line 16

Warning: include() [function.include]: Failed opening 'themes//homepage.php' for inclusion (include_path='.:/usr/lib/php') in /home/planlond/public_html/index.php on line 16

I know that it's because I havn't done something with the .inc file, but to be honest I'm, a bit clueless in regard to all this....a simple design and upload it is not!! I'm using Dreamweaver.

HELP!!

Thank you for your time!

Beks XX

Check where include directory is. If you are executing a script in, say for example, www/site/test/1.php and you are trying to include a file eg. functions.php, which is in www/site/include folder, you should give, include ("../include/functions.php"); because that's where the file is. If you give, include ("include/functions.php"); it wont be able to find it, hence, you get this error.

That's great, thankyou (although still having great difficulty!!) Sorry to be a pain, but is there a quick simple way I can display a static page on the URL whilst I figure this out? My boss isn't too pleased.. oops

Thankyou!

eg.

if(1!=2){
         include "error.php";
} else {
 include "includes/function.php";
include "includes/anotherpage.php";
........
}

The basic idea is, if(1!=2) will always return true. So, it will include error.php (where you can have a message saying the site is down or something). Make required changes in the path of all other include files and then remove the condition 1!=2.

That's great, thankyou (although still having great difficulty!!) Sorry to be a pain, but is there a quick simple way I can display a static page on the URL whilst I figure this out? My boss isn't too pleased.. oops

Thankyou!

You can dynamically check to see whether or not the file was included, and then automatically display the regular page or some other content.

First thing you'll want to do (at least when you're not testing it) is turn off error-reporting.

This will prevent the errors from showing up and telling your users that something is broke. You can do this by adding this line to the top of the file.

ini_set("display_errors", "Off");

Then, you can add a conditional statement to check if the file was included or not. If include() successfully finds the file, it returns "True." Otherwise, it will return false.

Seeing as you're including a lot of files, I'd create an error flag, set that flag to "True" if any of the files aren't included, and then at the end of the includes check whether or not the flag was set. Like this...

$error = false;
if ( !include("exampleFile.php")) {
  //  There was an error, exampleFile.php wasn't found
  $error = true; }

if ( !include("exampleFile2.php")) {
  //  There was an error, exampleFile2.php wasn't found
  $error = true; }

if ($error == true) {
  //  There was an error
  //  Include your alternate info here
  //  Or use header("Location: http://domain.com/static-page.html"); to redirect
} else {
  //  There was on error.  Execute the regular page here.
}

Or... you could just rename the file you're working with to something else. Then create a new file with the old name (and no includes). Once you've fixed the original file, change the names back.

Good luck,
- Walkere

This article has been dead for over six months. Start a new discussion instead.