Dustin Posted September 4, 2007 Share Posted September 4, 2007 <?php $d=date ("D m"); if ($d="sept07"); echo "it's fall"; else echo "it's not fall"; ?> it's small but hey it's my first day. but I get this error Parse error: syntax error, unexpected T_ELSE in /home/theweath/public_html/dustintest/dustintestphp.php on line 5 Thoughts? Quote Link to comment https://forums.phpfreaks.com/topic/67964-solved-php-error/ Share on other sites More sharing options...
darkfreaks Posted September 4, 2007 Share Posted September 4, 2007 Try: <?php $d=date ("D,m"); if ($d=="sept 07"){ echo ("it's fall"); }else echo {("it's not fall");} echo" ";?> Quote Link to comment https://forums.phpfreaks.com/topic/67964-solved-php-error/#findComment-341613 Share on other sites More sharing options...
Fadion Posted September 4, 2007 Share Posted September 4, 2007 no it should be: <?php $d = date("M y"); if($d == "sept 07"){ echo "it's fall"; } else{ echo "it's not fall"; echo " "; } ?> For comparison u should have the equality operators "==". Date("M y") should give u a date like "sept 07". Quote Link to comment https://forums.phpfreaks.com/topic/67964-solved-php-error/#findComment-341619 Share on other sites More sharing options...
Dustin Posted September 4, 2007 Author Share Posted September 4, 2007 Now I get this. Parse error: syntax error, unexpected ';' in /home/theweath/public_html/dustintest/dustintestphp.php on line 3 Quote Link to comment https://forums.phpfreaks.com/topic/67964-solved-php-error/#findComment-341622 Share on other sites More sharing options...
darkfreaks Posted September 4, 2007 Share Posted September 4, 2007 there is no ; on line 3? Quote Link to comment https://forums.phpfreaks.com/topic/67964-solved-php-error/#findComment-341625 Share on other sites More sharing options...
Fadion Posted September 4, 2007 Share Posted September 4, 2007 If u're talking about my code, it is ok!!. Also i made an error with the date comparison. It should be: if($d == "Sep 07"){ Quote Link to comment https://forums.phpfreaks.com/topic/67964-solved-php-error/#findComment-341633 Share on other sites More sharing options...
sstangle73 Posted September 4, 2007 Share Posted September 4, 2007 <?php $d = date("M y"); if($d == "sept 07"){ echo "it's fall"; } else{ echo "it's not fall"; echo " "; } ?> worked fine for me? is there something else on that page but that? Quote Link to comment https://forums.phpfreaks.com/topic/67964-solved-php-error/#findComment-341646 Share on other sites More sharing options...
Dustin Posted September 4, 2007 Author Share Posted September 4, 2007 yea it was fine. it just had some fillers or something when I copied it. I got it working with this code. <?php $d==date ("DM"); if ($d=="oct 28th") echo "it is fall"; else echo "it is not fall"; ?> Question for you folks is... how do you make it say it is fall? Quote Link to comment https://forums.phpfreaks.com/topic/67964-solved-php-error/#findComment-341652 Share on other sites More sharing options...
sstangle73 Posted September 4, 2007 Share Posted September 4, 2007 when it is fall Quote Link to comment https://forums.phpfreaks.com/topic/67964-solved-php-error/#findComment-341655 Share on other sites More sharing options...
Dustin Posted September 4, 2007 Author Share Posted September 4, 2007 so when oct 28th comes around the message will change? how does it know that? Quote Link to comment https://forums.phpfreaks.com/topic/67964-solved-php-error/#findComment-341657 Share on other sites More sharing options...
darkfreaks Posted September 4, 2007 Share Posted September 4, 2007 <?php $d==date ("D,M"); if ($d=="oct 28th"){ echo "it is fall"; }else{ echo "it is not fall";} ?> Quote Link to comment https://forums.phpfreaks.com/topic/67964-solved-php-error/#findComment-341659 Share on other sites More sharing options...
Fadion Posted September 4, 2007 Share Posted September 4, 2007 $d==date ("DM"); should be: $d=date ("DM"); The "DM" u used in date() make no sense for what u are aiming. "D" will give u "Mon", "Tue" etc. The full "DM" will give u for today: "Wed Sep". For lets say "Oct 28" u will need "M j" where "j" is the day of the month without leading zeros. Quote Link to comment https://forums.phpfreaks.com/topic/67964-solved-php-error/#findComment-341661 Share on other sites More sharing options...
Fadion Posted September 4, 2007 Share Posted September 4, 2007 so when oct 28th comes around the message will change? how does it know that? The script is such that when the date is 28 October it will print the message, otherwise print the other message. The full one should be: <?php $d = date("M j"); if($d == "Oct 28"){ echo "it's fall"; } else{ echo "it's not fall"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/67964-solved-php-error/#findComment-341662 Share on other sites More sharing options...
darkfreaks Posted September 4, 2007 Share Posted September 4, 2007 <?php $d=date ("F,j"); if ($d=="octtober 28th"){ echo "it is fall"; }else{ echo "it is not fall";} ?> Quote Link to comment https://forums.phpfreaks.com/topic/67964-solved-php-error/#findComment-341665 Share on other sites More sharing options...
sstangle73 Posted September 4, 2007 Share Posted September 4, 2007 exactly what the code says when $d == date ("D,M"); which shows today's date. if you wanna try it try this code <?php $d=date ("M j"); if ($d=="Sep 4"){ echo "it is 9/4"; }else{ echo "it isnt 9/4";} ?> Quote Link to comment https://forums.phpfreaks.com/topic/67964-solved-php-error/#findComment-341668 Share on other sites More sharing options...
d22552000 Posted September 4, 2007 Share Posted September 4, 2007 LMFAO this is hilarious.. YOu know this only tells it if it is EXACTLY october 28 and not any day before or after. So itll only tell you teh start of fall, and next day itll say it snot fall !!! Quote Link to comment https://forums.phpfreaks.com/topic/67964-solved-php-error/#findComment-341671 Share on other sites More sharing options...
Fadion Posted September 4, 2007 Share Posted September 4, 2007 exactly what the code says when $d == date ("D,M"); which shows today's date. if you wanna try it try this code <?php $d=date ("M j"); if ($d=="Sep 4"){ echo "it is 9/4"; }else{ echo "it isnt 9/4";} ?> What's the difference of this to mine code? Quote Link to comment https://forums.phpfreaks.com/topic/67964-solved-php-error/#findComment-341672 Share on other sites More sharing options...
sstangle73 Posted September 4, 2007 Share Posted September 4, 2007 my code has it passing on sept 4th and failing every other date so he can see what happens when it passes. Quote Link to comment https://forums.phpfreaks.com/topic/67964-solved-php-error/#findComment-341679 Share on other sites More sharing options...
d22552000 Posted September 4, 2007 Share Posted September 4, 2007 uh.. today is Sept 5... -,-. Quote Link to comment https://forums.phpfreaks.com/topic/67964-solved-php-error/#findComment-341682 Share on other sites More sharing options...
Fadion Posted September 5, 2007 Share Posted September 5, 2007 my code has it passing on sept 4th and failing every other date so he can see what happens when it passes. The codes are totally alike with a string of difference. Anyway not that it really matters. @d22552000, id say good point. Probably he can use smth like: $date = date("M j"); list($month, $day) = explode(' ', $date); $day = intval($day); if($month == 'Sept' and $day >= 7){ echo "It is Fall"; } else{ echo "No its not"; } Or whatever like that which makes it work. Quote Link to comment https://forums.phpfreaks.com/topic/67964-solved-php-error/#findComment-341683 Share on other sites More sharing options...
darkfreaks Posted September 5, 2007 Share Posted September 5, 2007 Try that: <?php $d=date ("F j"); if ($d=="September 05"){ echo "it is September 05"; }else{ echo "it is not September 05";} ?> Quote Link to comment https://forums.phpfreaks.com/topic/67964-solved-php-error/#findComment-341684 Share on other sites More sharing options...
Dustin Posted September 5, 2007 Author Share Posted September 5, 2007 It's the 4th in the US... Plus I want something that AUTOMATICALLY changes. EDIT: Nevermind, thank you. Quote Link to comment https://forums.phpfreaks.com/topic/67964-solved-php-error/#findComment-341687 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.