SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Addict
    Join Date
    Feb 2003
    Location
    durango
    Posts
    211
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Strange PHP Issue - Download page in firefox?

    Hi All,

    I have a very strange problem. I have a site that has been up for years. For some reason today one page on the site stopped working. The page usually displays a chaper of a book that students can read online.

    Now, FireFox tries to download the PHP page. IE either says the page is not available or just churns without doing anything. Below is a link for the page. Usually you would get an error saying you are not logged in but now it just doesn't work. Please note that all other PHP pages work fine. Also, I did modify a page that is linked to this one but I didn't change the link.

    Any ideas?

    https://www.apelslice.com/members/bo...2&page_ID=5537

    Thanks,

    Scott
    If I only had a brain.

  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    16,430
    Mentioned
    160 Post(s)
    Tagged
    1 Thread(s)

    page as download

    When I request https://www.apelslice.com/members/book_read_apel.php without the GET variables I get redirected to the https://www.apelslice.com/members/sorry.php?deny=no_session login page.
    But with the GET variables the page hangs (Using Opera).
    What does the script that deals with
    library=apel
    pro_ID=432
    page_ID=5537
    look like/do?

  3. #3
    SitePoint Addict
    Join Date
    Feb 2003
    Location
    durango
    Posts
    211
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    The main thing it does is get info about the book/chapter and then loads it into the page with this:

    <?php
    // include book on page

    echo "Title: " . $row_recBooks['pro_title'] . "<br />";
    echo "Chapter: " . $row_recChapters['page_chapter'] . "<br />";

    $path = $row_recChapters['page_url'];

    include('http://www.apelslice.com/books/' . $path);
    ?>

    I did notice that if the path is wrong, pointing to a file that does not exist, then the page loads normally with a "failed to load error"

    Thus, there could be a problem with the include statment/function?
    If I only had a brain.

  4. #4
    SitePoint Addict
    Join Date
    Feb 2003
    Location
    durango
    Posts
    211
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi all,

    I have been able to fix the problem by replacing the include() function with implode(file). It is working fine now but I still don't know why it broke in the first place.

    Thanks,

    sk
    If I only had a brain.

  5. #5
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    16,430
    Mentioned
    160 Post(s)
    Tagged
    1 Thread(s)

    implode?

    The code you posted looks like it is using results from a database query. So I imagine that it's the include file that uses the GET variables (unless there's more code before it).
    What confuses me is
    Quote Originally Posted by skadera
    by replacing the include() function with implode(file).
    The include() statement includes and evaluates the specified file
    but implode takes 2 arguments, "string glue" and an array,
    string implode ( string $glue , array $pieces )
    not a file, so I don't see how they could be interchangeable and still work. I suggest you do some more testing to ensure it really is working OK.

  6. #6
    SitePoint Addict
    Join Date
    Feb 2003
    Location
    durango
    Posts
    211
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    The GET is simply identifying the record in the database. The record has a field that holds the URL to the include file. I use that to find the file on the server.

    I was not clear about how I used implode(). Here is the actual code:

    $html = implode('', file('https://www.apelslice.com/books/' . $path));

    echo $html;

    According to the php.net site this converts the array file() into a string. I believe this is how the page needs to be displayed. Maybe I can just use file() and not worry about implode() at all. Please let me know if I am wrong about that. And, I still don't understand why file() will work and include() will not?

    Thanks for your help,

    sk
    If I only had a brain.

  7. #7
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    16,430
    Mentioned
    160 Post(s)
    Tagged
    1 Thread(s)

    include vs implode file

    file() returns an array, so if you want to use a string, implode will work.
    The only reason that I can think of as to why this would work and include wouldn't is possibly because of the URL (ie. the https://).
    include should be used on local files (no http) and unless allow_url_fopen is on, won't work with remote files. I'm guessing that for some reason file() isn't limited by these restrictions.

  8. #8
    SitePoint Addict
    Join Date
    Feb 2003
    Location
    durango
    Posts
    211
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok, I'll look into that. Thanks for the help.

    s
    If I only had a brain.


Bookmarks

Posting Permissions

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