Re: [PHP] problem with working with dates
Jacob, > I'm sorry to bother the newsgroup with this, but I've been racking my > brain on it for a few hours, and tried all the documentation, and > realize it's a coding problem that will take someone about 3 seconds to > figure out the error in. I have this code: =don't be sorry, these 'blind spots' are the strength of the group. =check out the differences between =, the assignment operator; and == the logical comparision operator; and === the logical type and comparison operator. You've used the first in the IF, when you want the second! =Regards, =dn > > $current_month = date (m); > $current_year = date (Y); > > > if("$current_month = 1") >{ > $previous_month = 12; > $previous_year = $current_year - 1; >} > > else > { > $previous_month = $current_month - 1; > $previous_year = $current_year; > } > print(""); > print(" >href=\"inquiry_reports.php?search=search&new_year=$previous_year&new_month=$previous_month\">Previous > Month"); > print(" >href=\"inquiry_reports.php?search=search&new_year=$current_year&new_month=$current_month\">Current > Month"); > print(""); > ?> > > but for some reason, no matter what the month, the first if statement > (if current_month = 1) is seen as true and executes... any suggestions? > > Cheers > > Jake Walker > [EMAIL PROTECTED] > > > -- > 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
RE: [PHP] problem with working with dates
Change it to == 1 if("$current_month == 1") Jason -Original Message- From: Jacob Walker [mailto:[EMAIL PROTECTED]] Sent: Friday, February 15, 2002 10:44 AM To: [EMAIL PROTECTED] Subject: [PHP] problem with working with dates I'm sorry to bother the newsgroup with this, but I've been racking my brain on it for a few hours, and tried all the documentation, and realize it's a coding problem that will take someone about 3 seconds to figure out the error in. I have this code: "); print("Previous Month"); print("Current Month"); print(""); ?> but for some reason, no matter what the month, the first if statement (if current_month = 1) is seen as true and executes... any suggestions? Cheers Jake Walker [EMAIL PROTECTED] -- 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
[PHP] problem with working with dates
I'm sorry to bother the newsgroup with this, but I've been racking my brain on it for a few hours, and tried all the documentation, and realize it's a coding problem that will take someone about 3 seconds to figure out the error in. I have this code: "); print("Previous Month"); print("Current Month"); print(""); ?> but for some reason, no matter what the month, the first if statement (if current_month = 1) is seen as true and executes... any suggestions? Cheers Jake Walker [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php