hosted by liquidweb


Go Back   Web Hosting Talk : Web Hosting Main Forums : Hosting Security and Technology : including a php file gives me an error. Not when include() through HTTP
Reply

Forum Jump

including a php file gives me an error. Not when include() through HTTP

Reply Post New Thread In Hosting Security and Technology Subscription
 
Send news tip View All Posts Thread Tools Search this Thread Display Modes
  #1  
Old
Premium Member
 
Join Date: Dec 2000
Location: Lowlands
Posts: 717
*

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



Sponsored Links
  #2  
Old
is useless
 
Join Date: Jan 2002
Location: Ohio
Posts: 3,075
Quote:
<?
require "file.php";
?>
Not that I'm, a php expert, but try this...

PHP Code:
<? 
require ('file.php'); 
?>
Well... it works fine for me....

hope this helps a little....

__________________
Don't like what I say? Ignore me because it will be the only way you can shut me up.

  #3  
Old
Registered 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.

Sponsored Links
  #4  
Old
Premium Member
 
Join Date: Dec 2000
Location: Lowlands
Posts: 717
Nope, I allready tried that one
It gives me the same error.

Anyone else?

  #5  
Old
Premium Member
 
Join Date: Dec 2000
Location: Lowlands
Posts: 717
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


  #6  
Old
Web 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...

  #7  
Old
Premium Member
 
Join Date: Dec 2000
Location: Lowlands
Posts: 717
Yes, it's in the same dir.

  #8  
Old
Premium Member
 
Join Date: Dec 2000
Location: Lowlands
Posts: 717
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?

  #9  
Old
New 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

  #10  
Old
Premium Member
 
Join Date: Dec 2000
Location: Lowlands
Posts: 717
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

Reply

Related posts from TheWhir.com
Title Type Date Posted
Zimbra Acquires Mezeo to Add Private File Sync-and-Share for Enterprises, Service Providers Web Hosting News 2014-07-15 16:23:14
Dropbox Vulnerability Allows Unauthorized Access of User Files Web Hosting News 2014-05-07 14:31:27
Unusual DNS Error Leads to Internet Outage in China Web Hosting News 2014-01-21 12:16:24
Egnyte Launches Program to PRISM-Proof Enterprise Cloud File-sharing Web Hosting News 2013-09-27 13:45:48
IceWEB Releases Version 3.0 of Cloud Storage Solution Web Hosting News 2013-08-28 11:11:13


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
Postbit Selector

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump
Login:
Log in with your username and password
Username:
Password:



Forgot Password?
WHT Host Brief Email:

We respect your privacy. We will never sell, rent, or give away your address to any outside party, ever.

Advertisement:
Web Hosting News:
WHT Membership
WHT Membership



 

X

Welcome to WebHostingTalk.com

Create your username to jump into the discussion!

WebHostingTalk.com is the largest, most influentual web hosting community on the Internet. Join us by filling in the form below.


(4 digit year)

Already a member?