Jump to content

[SOLVED] PHP error


Dustin

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/67964-solved-php-error/#findComment-341652
Share on other sites

$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.

Link to comment
https://forums.phpfreaks.com/topic/67964-solved-php-error/#findComment-341661
Share on other sites

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";
}
?>

Link to comment
https://forums.phpfreaks.com/topic/67964-solved-php-error/#findComment-341662
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/67964-solved-php-error/#findComment-341683
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.