Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 10 of 10
  1. #1
    Regular Coder
    Join Date
    Mar 2005
    Posts
    735
    Thanks
    4
    Thanked 1 Time in 1 Post

    <body> not loading when there's if statement

    Is there any way to make this work?
    PHP Code:
    function theOnload(){
        echo 
    "<body style=\"background-color: #515151;\"";
        if(
    $_GET["works"] == "home" or $_GET["works"] == ""){
            echo 
    " onLoad=\"myLatestWorks();\"";
        )
        echo 
    " >\n";

    The onLoad shouLd load a popup div tag on the home page. If I block:
    PHP Code:
    function theOnload(){
        echo 
    "<body style=\"background-color: #515151;\"";
        
    /*if($_GET["works"] == "home" or $_GET["works"] == ""){
            echo " onLoad=\"myLatestWorks();\"";
        )*/
        
    echo " >\n";

    The page loads if not it shows blank.
    Compare bible texts (and other tools):
    TheWheelofGod

  • #2
    Regular Coder
    Join Date
    Dec 2009
    Location
    UK
    Posts
    495
    Thanks
    0
    Thanked 58 Times in 58 Posts
    PHP Code:
    function theOnLoad() {
        echo 
    '<body style="background-color: #515151"'.
            ((!isset(
    $_GET['works']) || $_GET['works'] == 'home' || $_GET['works'] == '') ? ' onload="myLatestWorks();">' '>');

    Try that
    My site: JayGilford.com
    Resources:
    PHP Pagination Class | Getting all page links | Handling PHP Errors properly
    If you like a users help, show your appreciation with the rep and thanks buttons :)

  • #3
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,502
    Thanks
    8
    Thanked 1,089 Times in 1,080 Posts
    With PHP, "or" is ||

    if($_GET["works"] == "home" || $_GET["works"] == ""){

    You're getting a blank screen because PHP failed and you don't have
    error reporting turned-on. Turn on PHP error reporting via your PHP config
    with your webhost control panel or using .htaccess

  • #4
    Regular Coder
    Join Date
    Dec 2009
    Location
    UK
    Posts
    495
    Thanks
    0
    Thanked 58 Times in 58 Posts
    That wouldn't throw an error. It's perfectly logical to have OR written there. They both work
    http://www.php.net/manual/pl/languag...rs.logical.php
    My site: JayGilford.com
    Resources:
    PHP Pagination Class | Getting all page links | Handling PHP Errors properly
    If you like a users help, show your appreciation with the rep and thanks buttons :)

  • #5
    Regular Coder
    Join Date
    Nov 2009
    Location
    Hamilton, New Zealand
    Posts
    126
    Thanks
    0
    Thanked 17 Times in 17 Posts
    PHP Code:
    global $_GET
    Is required within the function I'm pretty sure.
    Affordable Web Design (New Zealand Based)
    Internet Marketing Guru
    PHP/mySQL Expert
    -------------------------------------------

  • #6
    Regular Coder
    Join Date
    Dec 2009
    Location
    UK
    Posts
    495
    Thanks
    0
    Thanked 58 Times in 58 Posts
    $_GET is a global, so it's not needed. Same as $_POST, $REQUEST, $_SESSION and $_COOKIE
    My site: JayGilford.com
    Resources:
    PHP Pagination Class | Getting all page links | Handling PHP Errors properly
    If you like a users help, show your appreciation with the rep and thanks buttons :)

  • #7
    Regular Coder
    Join Date
    Nov 2009
    Location
    Hamilton, New Zealand
    Posts
    126
    Thanks
    0
    Thanked 17 Times in 17 Posts
    Uh indeed.
    Affordable Web Design (New Zealand Based)
    Internet Marketing Guru
    PHP/mySQL Expert
    -------------------------------------------

  • #8
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,861
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    Could you post a link to your page?
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #9
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,502
    Thanks
    8
    Thanked 1,089 Times in 1,080 Posts
    I wonder if maybe the variable "works" does not exist with the $_GET.
    Would that cause a PHP "warning" ... and because the error reporting is
    not enabled, it is throwing a blank screen? So, he needs to suppress warnings,
    and turn-on error message to see what's happening?

  • #10
    Regular Coder
    Join Date
    Dec 2009
    Location
    UK
    Posts
    495
    Thanks
    0
    Thanked 58 Times in 58 Posts
    At best it would cause an undefined index NOTICE, but yeah that might be enough to throw it
    My site: JayGilford.com
    Resources:
    PHP Pagination Class | Getting all page links | Handling PHP Errors properly
    If you like a users help, show your appreciation with the rep and thanks buttons :)


  •  

    Posting Permissions

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