Hi,

I'm using Windows Vista, I have Apache HTTP server 2.2 running and am using PHP 5.2.17.

I’m having a problem remotely running a php script on the web server. I run this script locally below…

<?php
$file = fopen ("http://localhost/Epointment/testphp.php", "r");
if (!$file) {
    echo "<p>Unable to open remote file.\n";
    exit;
}
while (!feof ($file)) {
    $line = fgets ($file, 1024);
    /* This only works if the title and its tags are on one line */
    if (preg_match ("@\<title\>(.*)\</title\>@i", $line, $out)) {
        $title = $out[1];
		echo "/n".$title."/n";
        break;
    }
}
fclose($file);
?>

And after about 30 seconds get back…

PHP Warning: file_get_contents(http://localhost/Epointment/testphp.php): failed to open stream: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host failed to respond.

As this will be used in the real world I can’t really use a Path instead of the URL and I have tested it on a ‘real’ web server (one that’s not on my pc and not localhost) and it works and I have also run the testphp.php script ok directly on the webserver.

Thanks for any help…

Recommended Answers

All 2 Replies

What happens if you put that URL in a browser on that computer?

May tell you what is going on and also check the apache logs for the errors when it tries to get the page.

I've sorted in now..by putting my ip address in instead of localhost. Maybe localhost has been redefined somewhere..but it works thats the main thing.
How do I mark this topic has solved..thats the next issue..or shall I start another thread to resolve that :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.