Results 1 to 10 of 10
Hybrid View
-
03-26-2002, 05:40 PM #1Web Hosting Master
- Join Date
- Dec 2000
- Location
- Lowlands
- Posts
- 718
including a php file gives me an error. Not when include() through HTTP
Hi all!
When I try to include a php file like this:
<?
require "file.php";
?>
I get this error:
Fatal error: Failed opening required file.php'
(include_path='.:/usr/share/php') in /home/test/public_html/file.php on line 1
But when I do it like this:
<?
require "http://mydomain.com/file.php";
?>
it works!
Why is this? I can't figure out why because on some clients it does work both ways.
What is configured wrong here?
Thank you,
Domenico
-
03-26-2002, 06:53 PM #2is a threadkiller
- Join Date
- Jan 2002
- Location
- Ohio
- Posts
- 3,155
<?
require "file.php";
?>
PHP Code:<?
require ('file.php');
?>
hope this helps a little....Don't like what I say? Ignore me.
-
03-26-2002, 07:31 PM #3Registered User
- Join Date
- Mar 2002
- Posts
- 1,003
Check your php.ini file and make sure that "include_path" has no entry next to it.
-
03-26-2002, 07:32 PM #4Web Hosting Master
- Join Date
- Dec 2000
- Location
- Lowlands
- Posts
- 718
Nope, I allready tried that one
It gives me the same error.
Anyone else?
-
03-26-2002, 07:40 PM #5Web Hosting Master
- Join Date
- Dec 2000
- Location
- Lowlands
- Posts
- 718
Before there was .:/usr/share/php behind it but I removed it and restarted apache and now the error is:
Fatal error: Failed opening required 'd_projects.php?show=10' (include_path='') in /home/test/public_html/file.php on line 2
-
03-27-2002, 03:53 AM #6Web Hosting Master
- Join Date
- Aug 2000
- Posts
- 2,750
um... are you sure the file exists in the same dir as the script??
The Php Support Desk
http://www.phpsupportdesk.com
Custom programming - kunal @ e-phoria.com
http://www.pingzine.com - Ping!Zine. the FREE, FRESH and EXCITING Web Hosting Magazine...
-
03-27-2002, 05:16 AM #7Web Hosting Master
- Join Date
- Dec 2000
- Location
- Lowlands
- Posts
- 718
Yes, it's in the same dir.
-
03-27-2002, 05:37 AM #8Web Hosting Master
- Join Date
- Dec 2000
- Location
- Lowlands
- Posts
- 718
Let me rephrase my problem because I forgot to mention something.
What I want to use but doesn't work is:
<?
require "file.php?show=10";
?>
This works now:
<?
require "file.php";
?>
So why is this then?
-
03-27-2002, 06:02 AM #9New Member
- Join Date
- Mar 2002
- Location
- UK
- Posts
- 2
Hi,
You cannot include/require a file with any parameters passed to it directly as php looks for a file called "file.php?show=10" rather than just "file.php".
If show is not already defined in your script change it to the following:
<?
$show=10;
require "file.php";
?>
And it will be included correctly as file.php can see the variable as it is already defined in the script, note this only works for direct includes and not using includes via http:// for which you should use:
<?
require "http://mydomain.com/file.php?show=10";
?>
HTH
-
03-27-2002, 06:10 AM #10Web Hosting Master
- Join Date
- Dec 2000
- Location
- Lowlands
- Posts
- 718
Thanks for telling Jamesl!
I thought of this but didn't tried it yet, stupid me
Anyways, this is what the manual says:
- To include the top downloaders, sorted by number of reviews and rating (greatest to least), insert this where you would like the top downloaders to appear: <? require "d_top.php?show=xx"; ?> Replace "xx" with the number of top "downloaders" to display.
hehehe, someone has to go back to school then