Hi. I'm using the following to open a URL but the script fails. I t gives me an error in the log file about a bad file descriptor in the fopen command and the script timeouts.

$fp = fopen ("http://www.domain.com", "r");

if (!$fp) {
show_error("The page does not exist");
} else {
while (!feof ($fp)) {
$buffer = fgets($fp, 4096);
$created_content .= $buffer;
}
fclose ($fp);
}

print $created_content;

If i use http://localhost in the fopen() it retrieves the page, it shows it and it pop ups a message "Out of stack space" error. It's external URL s that doesn't open them at all.

How can i open a url and retrieve its content?

Thanks
John

    Make sure fopen wrappers are enabled on your system,
    and then use $webpage = FILE('Http://mysite.com/');

    You may have more luck. You'll most likely want the entire file, and this is a better fit until you get it down.

      I can open the remote file using fopen:
      ($webfile = fopen("$url", "r"))
      But only if $url has no arguments. I need to open an url and specify some arguments like:

      $url=www.yourdaddy.com/daddy.php?item=101

      The argument kills it I'm pretty new at this, but I have two PHP manuals and I've scoured them for a solution, but, am at a loss.
      Any advice out there?
      Brian

        Write a Reply...