UnitedForums - UK Web Hosting Forum UnitedHosting Community Hosting Forums
Network and Server StatusCustomer SupportUK Web Hosting
UnitedHostingUnitedHosting Sitemap UK Hosting ForumUK Web HostingWeb Hosting ForumsUK Reseller HostingWeb Host CommunityUK Managed Dedicated ServersHosting Help and SupportUK Domain Name Registration

Go Back   UnitedForums.co.uk > UnitedHosting Community > Website Development & Scripting

Reply
 
Thread Tools Rate Thread Display Modes
Old 25th July 2003, 02:41 PM   #1 (permalink)
goodyear
Twoshoes
 
goodyear's Avatar
 
Join Date: Feb 2003
Posts: 99
PHP includes going wrong.

Hi

I'm trying to include a php file into another one, and it just won't do it. I do this all the time, and I can't see what's wrong. The file that does the including runs:

PHP Code:
<?php

require_once('wrapper.php') or die("Cannot open wrapper file.");

print_header("home");

?>
<p>The Home Page</p>

<?php

print_footer
();

?>
And the error it throws is:
Quote:
Warning: main(1): failed to open stream: No such file or directory in /home/virtual/site**/fst/var/www/html/church/index.php on line 3

Fatal error: main(): Failed opening required '1' (include_path='.:/php/includes:/usr/share/php') in /home/virtual/site**/fst/var/www/html/church/index.php on line 3
(** edited becasue I'm paranoid!)

Now, wrapper.php is in the same directory as index.php.

So what gives?

Goodyear
goodyear is offline   Reply With Quote
Old 25th July 2003, 02:55 PM   #2 (permalink)
goodyear
Twoshoes
 
goodyear's Avatar
 
Join Date: Feb 2003
Posts: 99
Okay, took out the or die() construct, and it worked.

Was there something wrong with my syntax, there?
goodyear is offline   Reply With Quote
Old 25th July 2003, 08:18 PM   #3 (permalink)
Christopher
Registered User
 
Join Date: Jul 2003
Posts: 21
I don't think the include() functions (including require, require_once() and include_once()) return a value. So you were testing a null value. At the bottom of your included file you could add "return true;" to make it work.

Looks like that to me anyway, but I don't see why that would prevent the inclusion of the file... Was the file still included, just with the error message?
__________________
DevBox.net - Developer Forums
DevBox.net website coming soon
Christopher is offline   Reply With Quote
Old 26th July 2003, 12:13 AM   #4 (permalink)
goodyear
Twoshoes
 
goodyear's Avatar
 
Join Date: Feb 2003
Posts: 99
Nah. Wasn't included - it couldn't find the file. Very, very strange. Still, it's working now.
goodyear is offline   Reply With Quote
Old 27th July 2003, 04:48 PM   #5 (permalink)
leafish_paul
web monkey
 
leafish_paul's Avatar
 
Join Date: Apr 2003
Location: North Wales
Posts: 331
Send a message via ICQ to leafish_paul Send a message via MSN to leafish_paul
From what I can gather from the PHP manual, both 'require' and 'require_once' statements throw a fatal error and halt the execution of the script if the file isn't found anyway, so there is no need for an '...or die...' statement.
__________________
paul byrne - web monkey
paul.leafish.co.uk | www.leafish.co.uk
leafish_paul is offline   Reply With Quote
Old 27th July 2003, 04:55 PM   #6 (permalink)
goodyear
Twoshoes
 
goodyear's Avatar
 
Join Date: Feb 2003
Posts: 99
Yeah, that's the way it's working now.
Thanks.
goodyear is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


All times are GMT. The time now is 02:13 PM.

UK Web Hosting  |  UK Reseller Hosting  |  UK Dedicated Servers UnitedHosting  |  UnitedSupport  |  UnitedForums  |  SEO by vBSEO 3.0.0
Copyright © 1998-2008 United Communications Limited. All Rights Reserved. Registered in England and Wales 3651923 - VAT Reg No. 737662309