Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Blank page because of an echo

  1. #1
    Join Date
    Aug 2007
    Location
    Brazil
    Posts
    56
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Blank page because of an echo

    Hi everyone.
    I've been having some problems with a PHP implementation here. I have to use a .txt file as a database for the Updates section of this website. I already found a way of doing it, but I still haven't figure out a way of passing the id of the news the user is clicking to the page that is loaded when you click the link More >>.

    I thought this was right:
    PHP Code:
    echo "<li><strong>" $story[1] . "</strong> - " $story[2] . ". <a href=\"internal/news.php?id=".story[0]."\">More &gt;&gt;</a></li>"
    It works perfectly when I don't try to pass the id to the link. But whenever I try to include it, it stops working and gives me a blank page, what I learned that occurs when there's an error in the code. So where is the error? I can't see a reason for it to not work.

    -----

    EDIT: I forgot to say that I posted the link for the .html page so you can see something similar to what I want to achieve. To see what's happening with the .php, just click the link and then change the extension from .html to .php.
    Last edited by naiani; 08-31-2007 at 02:18 PM.

  2. #2
    Join Date
    Jul 2006
    Location
    just north of Boston, MA
    Posts
    1,806
    Thanks
    13
    Thanked 72 Times in 72 Posts

    Default

    i dont see anything wrong per the code that you posted, but do you have access to the error being given?

  3. #3
    Join Date
    Aug 2007
    Location
    Brazil
    Posts
    56
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I didn't have access to the error. I even tried to check the parsed source code (according to some goggled info, it should contain the error message), but nothing, it was literally a blank page.
    But I tried a new approach and it works now. I'm using list() = explode(); to separate the content into distinct vars ($id,$date,$title) and then use these vars in the echo. I don't know why, but apparently this was happening because I was using $story[0] to pass the id to the link in the echo. Why isn't it possible?

  4. #4
    Join Date
    Jul 2006
    Location
    just north of Boston, MA
    Posts
    1,806
    Thanks
    13
    Thanked 72 Times in 72 Posts

    Default

    yes but if there is a blank page then a php error is generated.. i was asking if you had access to the php error log to let us know what the fatal error was.

  5. #5
    Join Date
    Jan 2007
    Location
    Davenport, Iowa
    Posts
    2,385
    Thanks
    100
    Thanked 113 Times in 111 Posts

    Default

    Code:
    $data="<li><strong>";
    $data .= "$story[1]" ;
    $data .= "</strong> - ";
    $data .= "$story[2]" ;
    $data .= "<a href=\"internal/news.php?id=\"";
    $data .= "story[0].\'\'>More &gt;&gt;</a></li>";
    echo "$data";
    I'm a sloppy coder, but this should work.

    EDIT: Actually, I tested it and it worked.
    Last edited by james438; 08-31-2007 at 08:05 PM.

  6. #6
    Join Date
    Aug 2007
    Location
    Brazil
    Posts
    56
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by boogyman View Post
    yes but if there is a blank page then a php error is generated.. i was asking if you had access to the php error log to let us know what the fatal error was.
    No, I don't. I don't have access to any kind of "internal" aspects/features of the server.

  7. #7
    Join Date
    May 2006
    Location
    Sydney, Australia - Near the coast.
    Posts
    1,995
    Thanks
    0
    Thanked 8 Times in 7 Posts

    Default

    Try adding error_reporting(E_ALL); right under <?php...
    Peter - alotofstuffhere[dot]com - Email Me - Donate via PayPal - Got spare hardware? Donate 'em to me :) Just send me a PM.
    Currently: enjoying the early holidays :)
    Read before posting: FAQ | What you CAN'T do with JavaScript | Form Rules | Thread Title Naming Guide

  8. #8
    Join Date
    Mar 2006
    Location
    Cleveland, Ohio
    Posts
    574
    Thanks
    6
    Thanked 5 Times in 5 Posts

    Default

    And try wrapping your echoed code in single quotes so you don't have to slash the quotes, like so:

    PHP Code:
    echo '<a href="something.html">Sample "quotes"</a>'
    It makes the code simple and makes it easier to spot mistakes.
    Thou com'st in such a questionable shape
    Hamlet, Act 1, Scene 4

  9. #9
    Join Date
    Jul 2006
    Location
    just north of Boston, MA
    Posts
    1,806
    Thanks
    13
    Thanked 72 Times in 72 Posts

    Default

    Quote Originally Posted by alexjewell View Post
    And try wrapping your echoed code in single quotes so you don't have to slash the quotes, like so:

    PHP Code:
    echo '<a href="something.html">Sample "quotes"</a>'
    It makes the code simple and makes it easier to spot mistakes.
    also when you are parsing text you should break out of php as much as possible

  10. #10
    Join Date
    Mar 2006
    Location
    Cleveland, Ohio
    Posts
    574
    Thanks
    6
    Thanked 5 Times in 5 Posts

    Default

    Yeah, for example, say if you have an if statement, you could do this and not even use echo:

    PHP Code:
    <?php if(this){ ?>
    <!-- HTML HERE -->
    <?php ?>
    But we're getting off-subject a bit.
    Thou com'st in such a questionable shape
    Hamlet, Act 1, Scene 4

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
  •