A single = will assing a value, even inside an if statement A double = (ie ==) will perform a comparison between 2 values, returning true if they evaluate to the same value, false otherwise
A triple = (===) will do the same as ==, but also check that the types of the 2 variables match. Check out the PHP manual - http://www.php.net/manual/ - for more info HTH, Richy ========================================== Richard Black Systems Programmer, DataVisibility Ltd - http://www.datavisibility.com Tel: 0141 435 3504 Email: [EMAIL PROTECTED] -----Original Message----- From: Chris Barnes [mailto:[EMAIL PROTECTED]] Sent: 28 August 2002 17:12 To: Php-General (E-mail) Subject: [PHP] whats wrong with this? I just cant seem to work out why this doesn't work. My PHP book doesn't explain "if" statements very well so i have no idea if i am breaking a rule. $system_day = date("j"); for($day = 1; $day < 32; $day++){ if($day = $system_day){ echo "match!"; } else{ echo "no match"; } } the problem i am experiencing is that it seems the "if" statement is setting the $day value to equal $system_day instead of comparing their values.... if i add echo "Day: " . $day . " System_day: " . $system_day; before and after the if statement then the first result is something like Day: 1 System_day: 29 after the "if" statement has executed the result is Day: 29 System_day: 29 so you see, instead of "if" comparing $day to $system_day it is making $day equal to $system_day. any ideas why and how to fix this? help is most appreciated :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php