Forum Moderators: coopster

Message Too Old, No Replies

PHP causing IE to crash?

PHP IE Crashing

         

Stooshie

11:53 am on Aug 22, 2005 (gmt 0)

10+ Year Member



Hi there,

At first I thought the following problem was caused by the stylesheets I was using, but they are css2 compliant and the xhtml1-transitional is completely compliant.

Then, I thought it might be the server I was running locally, but I tried it on a different remote server and IE still crashed.

The I thought it might be my machine, but I tried it on another machine and it crashed as well.

It seems to happen when I change the stylesheet using the stylesheet picker I wrote.

I have a bar on every page with the following code:


<span id="choosestyle">
<strong>Styles:</strong>&nbsp;
<a href="set_css.php?css=_css/default.css">Default</a>&nbsp;<span class="pipe">¦</span>&nbsp;
<a href="set_css.php?css=_css/proportional.css">Proportional</a>&nbsp;<span class="pipe">¦</span>&nbsp;
</span>

the set_css.php page has the folowing code:


$cacheBuster = "?c=".rand(10000,100000);
// read in get request
$css_request = $_GET["css"];
// if request not blank
if(isset($css_request) && ($css_request!= ""))
{
// if request different from current choice
if($css_request!= $_COOKIE["css_choice"])
{
setcookie("css_choice", $css_request.$cacheBuster, time()+60*60*24*1000, '/');
}
}
$location_string = "Location: ".$_SERVER["HTTP_REFERER"];
header($location_string);

and every page has the next bit of code that decides on the style to use.

<?php
// add random query to end of style sheet call to make browser
// load a new page.
$cacheBuster = "?c=".rand(10000,100000);
// get user style (has cache buster already in string), if none,
// use default
if(isset($_COOKIE["css_choice"]) && $_COOKIE["css_choice"]!="")
{
$css_choice = $_COOKIE["css_choice"];
}
else
{
$css_choice = "_css/default.css".$cacheBuster;
}
?>
<style type="text/css" title="currentStyle" media="screen">
@import "<?php echo($css_choice);?>";
</style>
<style type="text/css" title="currentStyle" media="print">
@import "_css/printer_friendly.css";
</style>

Can anyone see anything wrong with my PHP?

Thankyou.

Andrew Wilson.

dcrombie

12:01 pm on Aug 22, 2005 (gmt 0)



PHP CAN'T cause IE (or any browser) to crash because it's a server-side language. You should be looking at what's OUTPUT by your PHP scripts as that's what the browser sees.

Stooshie

12:09 pm on Aug 22, 2005 (gmt 0)

10+ Year Member



Hi there,

I realise PHP is server side, but it does interact with the browser (headers, cookies etc).

The output is xhtml and css2 ccompliant so my thinking is that it may be something to do with PHP writing re-direct headers.

I am going to try the re-directing with javascript instead, which is annoying as I was trying to avoid any client side scripting at all.

I will post when I have tried it.

Andrew Wilson.