Enjoy an ad free experience by logging in. Not a member yet?
Register .
01-14-2010, 10:52 AM
PM User |
#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
01-14-2010, 12:25 PM
PM User |
#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
01-14-2010, 12:26 PM
PM User |
#3
Master Coder
Join Date: Jun 2003
Location: Cottage Grove, Minnesota
Posts: 9,046
Thanks: 8
Thanked 1,029 Times in 1,020 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
01-14-2010, 12:35 PM
PM User |
#5
Regular Coder
Join Date: Nov 2009
Location: Hamilton, New Zealand
Posts: 126
Thanks: 0
Thanked 17 Times in 17 Posts
Is required within the function I'm pretty sure.
01-14-2010, 12:37 PM
PM User |
#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
01-14-2010, 12:38 PM
PM User |
#7
Regular Coder
Join Date: Nov 2009
Location: Hamilton, New Zealand
Posts: 126
Thanks: 0
Thanked 17 Times in 17 Posts
Uh indeed.
01-14-2010, 12:51 PM
PM User |
#8
Supreme Master coder!
Join Date: Mar 2007
Location: N/A
Posts: 14,680
Thanks: 158
Thanked 2,182 Times in 2,169 Posts
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)
01-14-2010, 01:21 PM
PM User |
#9
Master Coder
Join Date: Jun 2003
Location: Cottage Grove, Minnesota
Posts: 9,046
Thanks: 8
Thanked 1,029 Times in 1,020 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?
01-14-2010, 01:22 PM
PM User |
#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
Jump To Top of Thread
Thread Tools
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
HTML code is Off
All times are GMT +1. The time now is 05:12 AM .
Advertisement
Log in to turn off these ads.