PHP include script with hypertext link not working.

A

Anonymous

Guest
Hi,
I have a problem when I try to make an include of a file on another server. I have seen two versions of the include script and tried with both, it just doesnt work. Th script works fine for an include "on site" but not with the hypertext link, then nothing happens or worse, it seems to hang.

The scripts I tried is :
<? php include 'http://www.mysite.com/myfile.php'; ?>
and
<? php include("http://www.mysite.com/myfile.php"); ?>

None of them works, but

<? php include 'myfile.php'; ?> works since its on the same server.

What am I doing wrong, or cant I include the same file on all my sites. I want to do this so I dont have to go to every site I have and update some things that are regulary updated and are the same for all sites.

Thanks in advance
 
You can't include a PHP file from another server, because when the file is retrieved it has already been parsed.
 
But on http://www.php.net they have examples that shows you can. I dont belive the other server would parse any files that are retrived remotely. The file is parsed locally on the server that retrievs, this is the example they have for the function "include":
Example 11-5. include() through HTTP

<?php

/* This example assumes that http://www.example.com is configured to parse .php
* files and not .txt files. Also, 'Works' here means that the variables
* $foo and $bar are available within the included file. */

// Won't work; file.txt wasn't handled by http://www.example.com as PHP
include 'http://www.example.com/file.txt?foo=1&bar=2';

// Won't work; looks for a file named 'file.php?foo=1&bar=2' on the
// local filesystem.
include 'file.php?foo=1&bar=2';

// Works.
include 'http://www.example.com/file.php?foo=1&bar=2';

$foo = 1;
$bar = 2;
include 'file.txt'; // Works.
include 'file.php'; // Works.

?>

So the question remains, why doesnt my code work?
 
does everything else in the include file work? or does it not include the file?
 
The include file works fine if I put it in a local (onsite) directory and include it with an local link eg. include("includes/file.php"); But it doesnt work with the the same file on another domain and an hyperlink include eg. include("http://www.domain.com/includes/file.php"); It hangs instead and I can see that the webserver seems to work at near 100% using PHP resources and the other sites get slow.
I have a dedicated win2003 server with PHP installed. Its hosted with Ev1servers.
 
Hi, I found the problem. just so you know. It was PHP .3 installed on the server and that didnt work good. I installed the new .7 version and everything works fine now.
Thanks for your help anyway :)

laiwa
 
Back
Top