Hi David
The problem I've got is that I need to import some data from one site to another whereby each site is on the same host but different servers.
I'm using the command
<?php
include'http://www.xxxxx.co.uk/xxxxx.html';
?>This worked on my previous host with no problems. This host is running Redhat Enterprise Linux Platform. They are also considering the problem but can't seem to come up with any credible solutions except iframes which are totally unacceptable.
Any ideas David
Kind regards
Bernard
www.uk-eshopping.co.uk


Hi Bernard, The first test I
Hi Bernard,
The first test I would do is to check that remote URL access is enabled (called URL wrappers). You can do this as follows:
test.php
<?php$url = "http://www.xxxxx.co.uk/xxxxx.html";
$file = fopen($url,"r");
if ($file)
{
$data = "";
while(!feof($file))
{
$data .= fread($file,1024);
}
print "Successfully read ".strlen($data)." bytes from URL";
}
else
{
print "Could not open URL";
}
?>
If you get the "Could not open URL" message (which I think is unlikely) then check the following PHP documentation for making sure that URL wrappers are enabled on your server / account:
http://uk2.php.net/manual/en/function.fopen.php
http://uk2.php.net/manual/en/ref.filesystem.php#ini.allow-url-fopen
If it does work, then we'll take it from there regarding why the URL is not being included properly...
Cheers,
David.
Tried that David and getting
Tried that David and getting the following error:
Warning: fopen(http://www.xxxxx.co.uk/testing.html) [function.fopen]: failed to open stream: Connection refused in /home/sites/xxxxx.co.uk/public_html/test-url-wrapper.php on line 3
Could not open URL
Bernard
Hi Bernard, That's
Hi Bernard,
That's interesting. It implies that URL wrappers are enabled on your server, which is good; however there is something else preventing the connection.
You mentioned that you got an error when changing the URL to a different file that doesn't exist. Can you try doing that with this test script and see if you get a different error message?
Cheers,
David.
David Sorry, I was running
David
Sorry, I was running that from the local site not a remote site, they already said it can't be run on itself. I run that again and now get:
Successfully read 28 bytes from URL
You then get the following
You then get the following error:
Warning: fopen(http://www.xxxxxx.co.uk/testingxxx.html) [function.fopen]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in /home/sites/yyyyyy.co.uk/public_html/test.php on line 3
Could not open URL
Hi Bernard; That's strange -
Hi Bernard;
That's strange - that include() is not working; but the code above does. Can you just try quickly, to confirm if you are downloading what you are expecting, replacing the success message with a simple print statement, which ultimately should have the same effect:
<?php$url = "http://www.xxxxx.co.uk/xxxxx.html";
$file = fopen($url,"r");
if ($file)
{
$data = "";
while(!feof($file))
{
$data .= fread($file,1024);
}
print $data;
}
?>
The above code should behave exactly the same as include()...
Cheers,
David.
That prints out the text
That prints out the text contained in the file
David I've tried that again
David
I've tried that again on a complete file that I would be using and it works fine.
Regards
Bernard
David Is there anything
David
Is there anything about this problem that I should put to the hosting people that thye should consider?
Thanks very much for your help, very much appreciated.
I have another item for you but I'll put that in another post later.
Kind regards
Bernard
Hi Bernard, I'm not sure
Hi Bernard,
I'm not sure really - but it would imply that include() behaves differently to fopen(). At least you have something that works - but i'll look into it and see if I can shed any further light...!
Cheers,
David.
Hi David Well, I got a
Hi David
Well, I got a replay back from the host as follows:
allow_url_fopen = on in a PHP file should solve this. I have done this for you now.
Really not sure what they're suggesting, can you throw any light on that?
Bernard
David I didn't expect a
David
I didn't expect a reply from them so quick at this time in the morning but here's what they say to my query:
"That needs to be in a file called php.ini[d][w] and it needs to be located in the same folder as the script that needs that change to the PHP config. It will cause that one functions to be overridden from the global PHP config on the server."
Seeing as I call scripts from all over the site is there a main place I can locate it. I remember from a while back that some of these php changes were placed in the .htaccess file or am I mistaken.
Bernard
Hi Bernard, The syntax for
Hi Bernard,
The syntax for setting that property within .htaccess is:
php_flag allow_url_fopen onHowever, I don't think that is the solution - because we have shown that fopen() by URL works in the above test scripts...
Cheers,
David.
You're absolutely correct
You're absolutely correct David, that's not the issue. I put it back to them and I'll let you know what they have to say.
Cheers
Bernard
David They're latest reply
David
They're latest reply is as follows:
'I've spoken to Sys Admin and they say that do not believe the include() and require() are the issue here.'
Well, if that's not the issue what is. I've put it back to them again but I can't see them resolving this one to be honest. At least the fopen script works for which I'm really grateful but the thought of the work ahead to implement it on all the necessary pages is giving me a headache.
Kind regards
Bernard
David Well here's the best
David
Well here's the best solution they could come up with:
"Out of interest, could you not replicate the content being called on to this account, rather than calling it from an external account?"
That's what I was trying to get away from, does a lot for time management when you have a number of sites all relying on the same data.
Thanks for your help
Cheers
Bernard
Hi David Hope you're
Hi David
Hope you're well.
So far they've not come up with any solution to the include() require() problem, and I don't think they will, but I have come across the following which seems to works very well:
<?php
$file = file_get_contents ('http://www.uk-eshopping.co.uk/xxxxx.php');
echo $file;
?>
Any comments on that?
Kind regards and happy Christmas
Bernard
Hi Bernard, That is
Hi Bernard,
That is essentially the same as we were doing above with the fopen() - just that it's all contained within a single PHP function. Still a mystery as to why include() doesn't work, but this is a perfectly good solution...
Merry Christmas to you to!
Cheers,
David.
Hi David We're slowly
Hi David
We're slowly getting somewhere. They added a php5.ini file to the route which contained allow_url_include = on. That worked ok for uk-loans-store.co.uk but when added to another site it failed to respond. It's back with them again - interesting this one
Regards
Bernard
Hi David Hope you had a nice
Hi David
Hope you had a nice Christmas.
Well, someone forgot to tell me that they had also added SetEnv DEFAULT_PHP_VERSION 5 to the .htaccess file. That, along with the php5.ini file makes it all work. I'm just hoping that all the coding I have on the other sites is compatible with this version. Doesn't solve the fact that it fails to work with ver 4 although I know it can work.
Cheers
Bernard
Hi Bernard, Thanks for
Hi Bernard,
Thanks for keeping the thread updated with your findings; and a merry Christmas to you too!
All the best,
David.