Forum Moderators: coopster
I have a script which attempts to run an external script on another server. For testing reasons it's 127.0.0.1
$url = "http://127.0.0.1/htdocs/UpdateCount.php?aID=".$aID;
$needle = 'Count:';
$contents = file_get_contents($url);
echo $contents;
if(strpos($contents, $needle)!== false) {
echo '<br />found';
} else {
echo '<br />not found';
}
I get the following error when I run it:
The specified CGI application misbehaved by not returning a complete set of HTTP headers. The headers it did return are:
PHP version 4.4.2
IIS win2k
Any ideas why?
I've seen various bug reports for this error but none are related to file_get_contents and I'm not doing anything strange in the external script. It just runs a DB query and echo's it to the page.
$url = "http://127.0.0.1/UpdateCount.php?aID=".$aID;
Also, why don't you execute the query from your own script?
The reason I can't use it directly, is that this script (running the file_get_contents) will actually be run on a different server. So, I'm running it on Server 2, it's supposed to retrieve a database value from server 1 and then use that in some of its variables.
I can't access server 1's DB directly cos of their security setup.
I ran the following, and it worked fine under Apache.
<?php
$aID = "0";
$url = "http://localhost/index.php?id=".$aID;
$needle = 'Count:';
$contents = file_get_contents($url);
echo $contents;
if(strpos($contents, $needle)!== false) {
echo '<br />found';
} else {
echo '<br />not found';
}
I'll try it on Apache later and see if that makes a difference.