I need help if PHP operators

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • OCCoder

    I need help if PHP operators

    I am trying to display a message on my webpage that should be triggered by a date check. The code is below (I removed all HTML tags for simplicity for now):

    Code:
    $m=date("m");
    $d=date("d");
    $y=date("Y");
    
    $int_d = (int)$d;
    
    //Thanksgiving
    
    if ($m="11"&&$y="2010"&&$int_d>23&&$int_d<=28)
    	{
    	echo 'Happy Thanksgiving!';
    	}
    
    //Holidays
    
    if ($m="12"&&$y="2010"&&$int_d>=18&&$int_d<=31)
    	{
    	echo 'Happy Holidays!';
    	}
    I want each statement to be executed during the appropriate dates i.e. "Happy Thanksgiving" from 11/24/2010 to 11/28/2010, and "Happy Holidays" from 12/18/2010 to 12/31/2010.

    The problem is that both statement are being executed regardless of the date?

    Thoughts?

    Thanks
  • code green
    Recognized Expert Top Contributor
    • Mar 2007
    • 1726

    #2
    Code:
    if ($m="11" && $y="2010
    Look at this test very carefully and think about assignment and comparison operators.

    Comment

    Working...