you need to use "==" instead of "="

"==" is used when comparing values (i.e. is this "==" to that)
"=" is used to set something's value (i.e. this "=" that)


-----Original Message-----
From: Chris Barnes [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, August 28, 2002 11:12 AM
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!";

                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 (
To unsubscribe, visit:

PHP General Mailing List (
To unsubscribe, visit:

Reply via email to