Changes to variable being partially ignored

I’m programming an iframe widget to go on a variety of other folks’ websites. One of my many variables is dedicated to telling the widget how to format itself. The variable is originally assigned from the URL like so:

[php]$_SESSION[‘format’] = $_GET[‘format’];[/php]

then used to pull in a particular stylesheet:

[php]<?php if ($_SESSION[format] > 0) {echo “”;}
else {} ?>[/php]

then used to insert an optional line break (or not):

<?php if ($_SESSION[format] = 1) {echo "
";} else {}?>

then echoed in a line that I’m using for testing purposes:

[php]Format: <?php echo $_SESSION[format]?>
[/php]

The problem is that when I change the value of the “format” variable, only the first of the three instances described above responds properly. The line break occurs no matter what, and the echo persistently produces a value of “1”. I have another variable that uses the exact same format for the test line [php]Constrain: <?php echo $_SESSION[constrain]?>[/php] and it updates properly when I change the value of the variable.

Any help would be much appreciated, this is driving me up the wall.

The error must be comparation, (==)
You write :

<?php if ($_SESSION[format] = 1) {echo "
";} else {}?>

You must write:

<?php if ($_SESSION[format] == 1) {echo "
";} else {}?>
The error must be comparation, (==)

You’re quite right. Darn typographical errors!

Thanks!

Sponsor our Newsletter | Privacy Policy | Terms of Service