View Full Version : Php Include Error
Josiah
02-27-2004, 03:24 PM
When I try to include a file from a page on a subdomain using PHP, I get this error:
Warning: main(../includes/nhl-sitenav.inc): failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in /home/josiahmack/domains/josiahmackenzie.com/public_html/nhl/tutorial.php on line 22
Warning: main(): Failed opening '../includes/nhl-sitenav.inc' for inclusion (include_path='.:/usr/local/lib/php') in /home/josiahmack/domains/josiahmackenzie.com/public_html/nhl/tutorial.php on line 22
Know of any way to fix it? :unsure:
dbmasters
02-27-2004, 05:33 PM
Use the subdomain
<?php include("http://subdomain.josiahmackenzie.com/whatever/file.php"); ?>
Josiah
02-27-2004, 06:52 PM
So instead of including files using a relative path, I should use the full path ("http://domain")?
dbmasters
02-27-2004, 09:09 PM
well, it's worth a try, that's how I have done it from time to time. It depends how the server looks at subdomains.
eugene
02-28-2004, 01:18 AM
Wait one second. Do you want to use the output generated by a php script, or to use variables and functions defined within it? If you want the latter, you cannot* do the include using http://subdomian.../. You must use a local server path. You may, however, be restricted from moving up the directory tree as it is not in your include path. This can be remedied via a change to the include path.
-Eugene
*Yes, technically, it is possible to construct a page that formats its output such that it CAN be used as valid php code for an include statement.
another include question
My directory structure looks something like this:
/includes/
/index.php
/About/
/About/about_stuff.php
/About/more_about_stuff.php
/Calendar/
/Contact/
Etc
I want to be able to include files from any directory. I think I know what to do but I wanted to be sure.
In the .htaccess file add something like the following line:
php_value include_path ".:/usr/local/lib/php:/home/(username)/domains/(domain.com)/public_html"
Then simply say:
<?php require("includes/template.part1.php"); ?>
and it works regardless of what directory I'm in.
What should I put for that path? Just the first part (the dot) and the 3rd part (full path from root to public directory)?
eugene
09-12-2004, 08:26 PM
Yep.
Thanks, that was easy.
What about the second one (I'm not sure where I got it):
/usr/local/lib/php
Is it supposedly the path to PEAR stuff? Do we have a special directory for things like that?
eugene
09-18-2004, 04:45 PM
You can install PEAR stuff wherever you would like as long as you include it in the path. I chose to place my PEAR things a directory up from public_html so that it was a little more protected.
vBulletin® v3.7.2, Copyright ©2000-2008, Jelsoft Enterprises Ltd.