Results 1 to 7 of 7

Thread: file(URL) causes a blank page

  1. #1

    Thread Starter
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    file(URL) causes a blank page

    One of my websites on a shared host has started behaving strangely. The file() function won't work when calling a URL. Here is what I tried, straight from php.net/function.file.

    PHP Code:
    start

    <?


    // Get a file into an array.  In this example we'll go through HTTP to get
    // the HTML source of a URL.
    $lines = file('http://www.mendhak.com/default.aspx');


    ?>

    finish
    The page comes out as blank for any URL. It gives an HTTP 200, but there is no markup at all when viewing source. Is there a way to make the page not depend on what's coming back from the HTTP request? I've also tried a try catch, still blank response.

    PHP Code:
    start

    <?

    try
    {

    // Get a file into an array.  In this example we'll go through HTTP to get
    // the HTML source of a URL.
    $lines = file('http://www.vbforums.com/index.php');
    }
    catch(Exception $e)
    {
    echo ('exception');
    }

    ?>

    finish
    The server is using PHP 5.2.5.

    Another question - I can do a phpinfo(), but is there anything in phpinfo() that I can look at to see whether such web requests are allowed or not?

  2. #2
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: file(URL) causes a blank page

    What do you get if you do var_dump($lines)? The setting you need is allow_url_fopen
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  3. #3

    Thread Starter
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: file(URL) causes a blank page

    Exactly the same as before. The presence of fopen on the page causes a blank response. I checked phpinfo and much to my chagrin, allow_url_fopen is set to On.

    Now I'm losing hope. Thanks. Again.

  4. #4
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: file(URL) causes a blank page

    A blank page "should" only be encountered when you have got error report set to off. Have a look at the error reporting settings in phpinfo and if you are not sure stick the following line at the top of the script:
    PHP Code:
    error_reporting(E_ALL); 
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  5. #5
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: file(URL) causes a blank page

    Quote Originally Posted by visualAd
    A blank page "should" only be encountered when you have got error report set to off.
    or if you're doing output buffering and an error somehow causes the buffer to be cleaned instead of flushed (admittedly, this is rather far-fetched — I don't think it can happen without writing code to do it).

  6. #6

    Thread Starter
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: file(URL) causes a blank page

    Error reporting is already set to E_ALL. Sorry I didn't mention that. Then again it would've been caught in the catch() block, wouldn't it? I'm going to let this question/functionality drop for now, I'll revisit it later if required. Thanks for your time.

  7. #7
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: file(URL) causes a blank page

    PHP errors are not exceptions, so no. The other settings you should look out for it the error_log and display_errors setting which controls other aspects of error control.

    You are making it very difficult to help you as there are no errors.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width