Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-14-2010, 10:52 AM   PM User | #1
gilgalbiblewhee
Regular Coder

 
Join Date: Mar 2005
Posts: 735
Thanks: 4
Thanked 1 Time in 1 Post
gilgalbiblewhee is an unknown quantity at this point
<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
gilgalbiblewhee is offline   Reply With Quote
Old 01-14-2010, 12:25 PM   PM User | #2
JAY6390
Regular Coder

 
Join Date: Dec 2009
Location: UK
Posts: 495
Thanks: 0
Thanked 58 Times in 58 Posts
JAY6390 is on a distinguished road
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 :)
JAY6390 is offline   Reply With Quote
Old 01-14-2010, 12:26 PM   PM User | #3
mlseim
Master Coder

 
mlseim's Avatar
 
Join Date: Jun 2003
Location: Cottage Grove, Minnesota
Posts: 9,046
Thanks: 8
Thanked 1,029 Times in 1,020 Posts
mlseim has a spectacular aura aboutmlseim has a spectacular aura aboutmlseim has a spectacular aura about
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
mlseim is offline   Reply With Quote
Old 01-14-2010, 12:32 PM   PM User | #4
JAY6390
Regular Coder

 
Join Date: Dec 2009
Location: UK
Posts: 495
Thanks: 0
Thanked 58 Times in 58 Posts
JAY6390 is on a distinguished road
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 :)
JAY6390 is offline   Reply With Quote
Old 01-14-2010, 12:35 PM   PM User | #5
Rebbu
Regular Coder

 
Join Date: Nov 2009
Location: Hamilton, New Zealand
Posts: 126
Thanks: 0
Thanked 17 Times in 17 Posts
Rebbu is on a distinguished road
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
-------------------------------------------
Rebbu is offline   Reply With Quote
Old 01-14-2010, 12:37 PM   PM User | #6
JAY6390
Regular Coder

 
Join Date: Dec 2009
Location: UK
Posts: 495
Thanks: 0
Thanked 58 Times in 58 Posts
JAY6390 is on a distinguished road
$_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 :)
JAY6390 is offline   Reply With Quote
Old 01-14-2010, 12:38 PM   PM User | #7
Rebbu
Regular Coder

 
Join Date: Nov 2009
Location: Hamilton, New Zealand
Posts: 126
Thanks: 0
Thanked 17 Times in 17 Posts
Rebbu is on a distinguished road
Uh indeed.
__________________
Affordable Web Design (New Zealand Based)
Internet Marketing Guru
PHP/mySQL Expert
-------------------------------------------
Rebbu is offline   Reply With Quote
Old 01-14-2010, 12:51 PM   PM User | #8
abduraooft
Supreme Master coder!

 
abduraooft's Avatar
 
Join Date: Mar 2007
Location: N/A
Posts: 14,680
Thanks: 158
Thanked 2,182 Times in 2,169 Posts
abduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really nice
Could you post a link to your page?
__________________
Quote:
The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)
abduraooft is offline   Reply With Quote
Old 01-14-2010, 01:21 PM   PM User | #9
mlseim
Master Coder

 
mlseim's Avatar
 
Join Date: Jun 2003
Location: Cottage Grove, Minnesota
Posts: 9,046
Thanks: 8
Thanked 1,029 Times in 1,020 Posts
mlseim has a spectacular aura aboutmlseim has a spectacular aura aboutmlseim has a spectacular aura about
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?
mlseim is offline   Reply With Quote
Old 01-14-2010, 01:22 PM   PM User | #10
JAY6390
Regular Coder

 
Join Date: Dec 2009
Location: UK
Posts: 495
Thanks: 0
Thanked 58 Times in 58 Posts
JAY6390 is on a distinguished road
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 :)
JAY6390 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:12 AM.


Advertisement
Log in to turn off these ads.