[SOLVED] Checking condition using 'if'...

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
dardsemail
Forum Contributor
Posts: 136
Joined: Thu Jun 03, 2004 9:02 pm

[SOLVED] Checking condition using 'if'...

Post by dardsemail »

I have a bit of code and I'm trying to use a conditional 'if' statement to check its value - unfortunately, I think I'm setting its value instead.

Here's the code:

Code: Select all

<?php
if ($_SESSION['state']=='LA')

?>
Am I setting the 'state' value or checking it? Its weird because I'm storing the $_SESSION value for 'state', but when I get to this page, it switches back to 'LA' no matter what I have entered on the previous pages to set it. That's why I suspect that this code is kind of iffy.

Am I checking the variable against 'LA' or setting it? Ideally, I'd like to just check it.

Thanks!
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

== is a comparison
= is an assignment
So you are comparing.

Do you have register_globals On? (a <?php phpinfo() ?. page will tell you.
If you do it would explain your problem.
dardsemail
Forum Contributor
Posts: 136
Joined: Thu Jun 03, 2004 9:02 pm

Post by dardsemail »

Thanks. Got it. Its working now.
Post Reply