Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Include external site in php file.

Status
Not open for further replies.

nerbonne

Technical User
Dec 11, 2006
99
US
Hi. I originally had my site coded in html and I used an iframe to include a status script that ran on a secondary site of mine.

I have since re-coded my site in php, but I am unable to figure out how to include the external script. I am already using "<?php include($path["docroot"]."status.php"); ?>" to include a local status.php file, but trying to use this same include for doesn't work.
 
Are you expecting to include the output from the remote script or the PHP code itself?

Have you echo'd the path that you're trying to include? Perhaps it is malformed - missing a key "\" character?

D.E.R. Management - IT Project Management Consulting
 
is $path['docroot'] a variable that you have defined or are you expecting it to be automagically populated?

are you perhaps looking for this kind of construct :

Code:
$url = "[URL unfurl="true"]http://".$_SERVER[/URL]['SERVER_NAME'] . "/status.php";
 
Two things. First, you must include the protocol in your URL, i.e. use Otherwise PHP is going to look for a local file.

Second, you need to have the URL fopen wrappers enabled for include() to read a URL. Check the output of phpinfo() to make sure that allow_url_fopen is turned on.
 
thedaver:

Yes, I expect the output from the remote script.

No, I have not tried echo'ing the patch. Not sure of the exact format.


jpadie:

I have not defined docroot, however it must be some kind of global variable because it does work.

Yes, I am interested in your code, but I'm not sure how to implement that. Doesn't appear that all of it is there.


AdaHacker:

I tried using the protocol in the URL and it didn't work. Possibly I am using the wrong method of trying to include the page. Could you post the complete code to do so?

I check allow_url_fopen and it is on.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top