Jump to content

switch problem in firefox


matuss

Recommended Posts

hi, i have this php code:

 

switch($int_value) {

case 1:

$_SESSION['test'] = "";

break;

case 2:

some code in case 2;

break;

case 3:

some code in case 3;

break;

}

 

the problem is, that $_SESSION['test'] is set to "" anytime, also when $int_value is 2 or 3...

in case that $int_value is 2, code for 2 is executed. but problem is, that also code for case 1 is executed, this problem is with $_SESSION variables...

 

strange is, that this problem is only in Mozilla Firefox!!

in IE and opera it works normaly and OK...

 

i asked on some forum, they told i can try to contact PHP server admin...

 

many thanks

Link to comment
https://forums.phpfreaks.com/topic/45947-switch-problem-in-firefox/
Share on other sites

no PHP issues will ever be as a result of the browser the client uses.  the browser is client-side, whereas any PHP issues will be present on the server's side of things.  the only client-based cause for session or cookie issues would be if your browser isn't set to allow them.

 

whenever debugging a switch statement for which you can't tell what case is being executed, try running an echo.  if the switch() is for some reason in an invisible area of the browser, you can always use javascript to make it in your face:

 

<?php

echo '<script type="text/javascript">alert("the integer value is '.$int_value.'.");</script>';

switch ($int_value)
{
  case 1:
    echo '<script type="text/javascript">alert("case number '.1.' was executed!");</script>';
    break;
  case 2:
    echo '<script type="text/javascript">alert("case number '.2.' was executed!");</script>';
    break;
}

?>

 

try running that - it should tell you both what the $int_value is, as well as which case is being executed.  could very well be a casting issue (ie. $int_value is actually a string).

really strange thing is, that this problem is only in firefox...

 

if i try to echo something within case, it is not diplayed.

only operations with SESSION are executed in case!!

also i tried to use

 

if ($int_val == 1) {
echo "i am here";
$_SESSION['test'] = "";
}

 

my $_SESSION['test'] variable was erased, even if $int_val was 2...but "I am here" dont appear..

 

if i use

if ($int_val == 1) {
echo "i am here";
//$_SESSION['test'] = "";
}

 

everything is ok, no erase of my variable occurs.

 

i dont know what to do, its bad only in firefox :(

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.