[FIXED] Conditional Statement Error in IE/AOL Browser

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
theda
Forum Contributor
Posts: 332
Joined: Sat Feb 19, 2005 8:35 am
Location: USA

[FIXED] Conditional Statement Error in IE/AOL Browser

Post by theda »

I'm not quite understanding this error, but when showing my website to friend who viewed my website in both AOL browser and IE, they say both my splash page and main layout page in the same page (whereas, it should show one or the either depending on if a cookie is saved or not). Which leads to the header errors. I believe if I some how could figure out what is causing the if else statement to break down and not work as intended, then the header errors would go away.

Which the strange part is, the snapshot i have shows that the person saved a cookie with the neccessary variables. I have the screenshot below.
Image

And here's my code, although it's pretty whacked up. (I haven't had the time to actually CLEAN it up)


The even odder part is when i view it in both Firefox and IE, it works perfectly for me (note that the person who had the IE/AOL errors said it worked fine in firefox). Any fixes?

Edit: I have edited the script a bit, cleaned it and simplified it to hasten any help.

Edit 2: I deleted the php code in this post; newer version is in a post below
Last edited by theda on Tue Jul 05, 2005 1:37 pm, edited 4 times in total.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

EDIT |

Oops, never noticed all that content is in a condition. Ouch... that's scary.

Maybe you should look into HEREDOC or using the syntax

Code: Select all

<?php
if ($foo) {
?>
This content is only shown if $foo evaluates a true
<?php
}
?>
gt;
This content is only shown if $foo evaluates a true
<?php
}
?>
. that's scary.

Maybe you should look into HEREDOC or using the syntax

Code: Select all

<?php
if ($foo) {
?>
This content is only shown if $foo evaluates a true
<?php
}
?>
yntax

Code: Select all

<?php
if ($foo) {
?>
This content. Ouch... that's scary.

Maybe you should look into HEREDOC or using the syntax

Code: Select all

&lt;?php
if ($foo) {
?&gt;
This content is only shown if $foo evaluates a true
<?php
}
?>
ver noticed all that content is in a condition. Ouch... that's scary.

Maybe you should look into HEREDOC or using the syntax

Code: Select all

<?php
if ($foo) {
?>
This content is only shown if $foo evaluates a true
<?php
}
?>
h... that's scary.

Maybe you should look into HEREDOC or using the syntax

Code: Select all

&lt;?php
if ($foo) {
?&gt;
This content is only shown if $foo evaluates a tontent is in a condition. Ouch... that's scary.

Maybe you should look into HEREDOC or using the syntax

Code: Select all

<?php
if ($foo) {
?>
This content is only shown if $foo evaluates a true
&lt;?php
}
?&gt;
ver noticed all that content is in a condition. Ouch... that's scary.

Maybe you should look into HEREDOC or using the syntax

Code: Select all

<?php
if ($foo) {
?>
This content is only shown if $foo evaluates a true
<?php
}
?>
[/php:1:37s a true
<?php
}
?>
ent is in a condition. Ouch... that's scary.

Maybe you should look into HEREDOC or using the syntax

Code: Select all

<?php
if ($foo) {
?>
This content is only shown if $foo evaluates a true
<?php
}
?>
ybe you should look into HEREDOC or using the syntax

Code: Select all

<?php
if ($foo) {
?>
This content is only shown if $foo evaluathp]
<?php
if ($foo) {
?>
This content is only shown if $foo evaluates a true
<?php
}
?>
t's scary.

Maybe you should look into HEREDOC or using the syntax

Code: Select all

<?php
if ($foo) {
?>
This content is only shown if $foo evaluates a true
<?php
}
?>
ver noticed all that content is in a condition. Ouch... that's scary.

Maybe you should look into HEREDOC or using the syntax

Code: Select all

<?php
if ($foo) {
?&gyou should look into HEREDOC or using the syntax

Code: Select all

&lt;?php
if ($foo) {
?&gt;
This content is only shown if $foo evaluates a true
&ver noticed all that content is in a condition. Ouch... that's scary.

Maybe you should look into HEREDOC or using the syntax

Code: Select all

<?php
if ($foo) {
?>
This content is only shown if $foo evaluates a true
<?php
}
?>
HEREDOC or using the syntax

Code: Select all

<?php
if ($foo) {
?>
This content is only shown if $foo evaluates a true
<?php
}
?>
Ouch... that's scary.

Maybe you should look into HEREDOC or using the syntax

Code: Select all

<?php
if ($foo) {
?>
This content is only shown if $foo evaluates a true
<?php
}
?>
<?php
if ($foo) {
?>
This content is only shown if $foo evaluates a true
<?php
}
?>
theda
Forum Contributor
Posts: 332
Joined: Sat Feb 19, 2005 8:35 am
Location: USA

Post by theda »

Im curious as to why you'd end a php tag in the middle of an if-else statement.

Edit: I just realized how much crap I have in my code. <_< Gahh....
theda
Forum Contributor
Posts: 332
Joined: Sat Feb 19, 2005 8:35 am
Location: USA

Post by theda »

Not to be a pest or anything, but no one has really mentioned any kind of answer to my question... So I'll rephrase it a little bit, and post the new code (which I slimmed down to just the parts that need to be looked at).

Question: For some reason, my if, elseif, else conditional statements screw up in Internet Explorer and AOL's browser (which is more or less IE). Instead of following "If(this){Show this}else{show this}" it does this: "if (this) {show this} and {show this}" It's as if I jsut coded "show this and this" and ignored the if and else part of it.

My new code:


Code: Select all

<?

// Deleting cookie Identity
	if (isset($del)) {
		setcookie('ver',$del, time()-60*60*24*30);
		header("Location: index.php");
	} else {
// Language Identity
	if (isset($HTTP_COOKIE_VARS['ver']) AND empty($HTTP_GET_VARS['ver'])) {
  		$ver = $HTTP_COOKIE_VARS['ver'];
	} elseif (isset($HTTP_GET_VARS['ver'])) {
  		$ver = $HTTP_GET_VARS['ver'];
  		setcookie('ver',$ver, time()+60*60*24*30);
	} else {
		setcookie('ver','$ver', time()-60*60*24*30);
include "img/splash.php";
	}

// Theme Identity
	if (isset($HTTP_COOKIE_VARS['the']) AND empty($HTTP_GET_VARS['the'])) {
		$the = $HTTP_COOKIE_VARS['the'];
	} elseif (isset($HTTP_GET_VARS['the'])) {
		$the = $HTTP_GET_VARS['the'];
		setcookie('the',$the, time()+60*60*24*30);
	} else {
		setcookie('the','see', time()+60*60*24*30);
		$the = "see";
	}
// URL Identity
	if ($id=="news") {
		$url = "?id=news"; 
	} elseif ($id=="links") {
		$url = "?id=links"; 
	} elseif ($id=="rants") {
		$url = "?id=rants"; 
	} elseif ($id=="photos") {
		$url = "?id=photos"; 
	} elseif ($id=="poems") {
		$url = "?id=poems"; 
	} elseif ($id=="conts") {
		$url = "?id=conts"; 
	} else {
		$url = "?id=news"; 
	}
		// Opposite Language Identity
	if($ver == "en")  {
		$ver2 = "de"; 
	} else {
		$ver2 = "en"; 
	}
// Page Identity
	if (isset($id)) {
		$id = $id;
	} else {
		$id = "news"; 
	}
// Load time Identity
$load = number_format(microtime(),2);
		include "img/main.php";
	}
?>
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

Not to be a pest.... But that code is interpreted and executed by your Webserver... And has nothing to do with the UserAgent you are using...

Code: Select all

ini_set('error_reporting', E_ALL);
ini_set('display_errors', TRUE);

// rest of your code
theda
Forum Contributor
Posts: 332
Joined: Sat Feb 19, 2005 8:35 am
Location: USA

Post by theda »

Well, not to be a pest again. LMAO, but it is. Apparently Firefox interpreted my <noscript> tag correctly, unlike IE/AOL, which only killed the javascript when i used <noscript>, while <noscript> killed everything after it. I figured out that I had nested half my code in the wrong conditional.


The fixed code:

Code: Select all

<?

// Deleting cookie Identity
	if (isset($del)) {
		setcookie('ver',$del, time()-60*60*24*30);
		header("Location: index.php");
	} else {
// Language Identity
	if (isset($HTTP_COOKIE_VARS['ver']) AND empty($HTTP_GET_VARS['ver'])) {
  		$ver = $HTTP_COOKIE_VARS['ver'];

// Theme Identity
	if (isset($HTTP_COOKIE_VARS['the']) AND empty($HTTP_GET_VARS['the'])) {
		$the = $HTTP_COOKIE_VARS['the'];
	} elseif (isset($HTTP_GET_VARS['the'])) {
		$the = $HTTP_GET_VARS['the'];
		setcookie('the',$the, time()+60*60*24*30);
	} else {
		setcookie('the','see', time()+60*60*24*30);
		$the = "see";
	}
// URL Identity
	if ($id=="news") {
		$url = "?id=news"; 
	} elseif ($id=="links") {
		$url = "?id=links"; 
	} elseif ($id=="rants") {
		$url = "?id=rants"; 
	} elseif ($id=="photos") {
		$url = "?id=photos"; 
	} elseif ($id=="poems") {
		$url = "?id=poems"; 
	} elseif ($id=="conts") {
		$url = "?id=conts"; 
	} else {
		$url = "?id=news"; 
	}
		// Opposite Language Identity
	if($ver == "en")  {
		$ver2 = "de"; 
	} else {
		$ver2 = "en"; 
	}
// Page Identity
	if (isset($id)) {
		$id = $id;
	} else {
		$id = "news"; 
	}
// Load time Identity
$load = number_format(microtime(),2);
		include "img/main.php";
	} elseif (isset($HTTP_GET_VARS['ver'])) {
  		$ver = $HTTP_GET_VARS['ver'];
  		setcookie('ver',$ver, time()+60*60*24*30);
		header("Location: index.php");
	} else {
		setcookie('ver','$ver', time()-60*60*24*30);
include "img/splash.php";
	}

	}
?>
Roja
Tutorials Group
Posts: 2692
Joined: Sun Jan 04, 2004 10:30 pm

Post by Roja »

theda wrote:Well, not to be a pest again. LMAO, but it is. Apparently Firefox interpreted my <noscript> tag correctly, unlike IE/AOL, which only killed the javascript when i used <noscript>, while <noscript> killed everything after it. I figured out that I had nested half my code in the wrong conditional.
You misunderstood what he meant:
timvw wrote:But that code is interpreted and executed by your Webserver... And has nothing to do with the UserAgent you are using...
You were saying the output problem (for a browser) was in the server-side code you had.

PHP runs the code. The code spits out output. The browser takes that output, and renders it.

Notice at no point does the browser have the option of changing the output or causing the execution of the backend code to change. :)

(To be fair, you could put in conditionals for such things, but your code doesn't have any)

Timvw's point was (simply restated) "The problem is on the backend. Clean up your code in general by checking for all warnings, which will probably solve it."

Since you changed/cleaned up your code several times, and have now solved it, his advice was worthwhile.
theda
Forum Contributor
Posts: 332
Joined: Sat Feb 19, 2005 8:35 am
Location: USA

Post by theda »

True, he was. And true you are. I didn't missinterpret it, I just didn't decide to let it stick in my head long enough TO interpret it ^_^;; I was slightly busy trying to find what was going on in the script.

So far, my website is XHtml compliant, Html 4.0 (HTML Tidy) compliant... PHP corrected... Website uses only divs and p tags... (instead of table/td and such).

Im wondering what I should do next... Hmm...
Roja
Tutorials Group
Posts: 2692
Joined: Sun Jan 04, 2004 10:30 pm

Post by Roja »

theda wrote: So far, my website is XHtml compliant, Html 4.0 (HTML Tidy) compliant... PHP corrected... Website uses only divs and p tags... (instead of table/td and such).

Im wondering what I should do next... Hmm...
Nice - impressive!

There are only about a thousand opensource projects that could use help with frontend code.. jump into one. :)
theda
Forum Contributor
Posts: 332
Joined: Sat Feb 19, 2005 8:35 am
Location: USA

Post by theda »

Dare I ask like where? ^_^;; I'm watching a movie and don't feel like searching google right now. ^_^;
AngusL
Forum Contributor
Posts: 155
Joined: Fri Aug 20, 2004 4:28 am
Location: Falkirk, Scotland

Post by AngusL »

http://www.sourceforge.net - Not sure how you'd find projects looking for peopple like you though... not used it much
theda
Forum Contributor
Posts: 332
Joined: Sat Feb 19, 2005 8:35 am
Location: USA

Post by theda »

I'm mostly looking for parts of php to learn. Like when I first started PHP, i learned how to include files (whoopdie do! lol), then I learned the conditionals, and lately have been working on cookies and skinning systems (And how to remove cookies too). Now I'm trying to find a good practical php snippet to learn and add to my website.

Edit: And if you haven't noticed yet... my websites' link is http://dumbass.ionichost.com
Post Reply