grucker Posted November 20, 2013 Share Posted November 20, 2013 I have had a different message appearing evry day based on the name of the day. I now want a message based on the date up to 31. I have tried messing to no no avail. Help will be appreciated $day_post = "includes/days"; $today = date('l');if (file_exists($day_post."/".$today.".php")) { /**echo "$day_post/".$today.".php"; **/include("$day_post/".$today.".php"); } else { echo "No thoughts came into my head $today";} Link to comment https://forums.phpfreaks.com/topic/284120-new-message-every-day/ Share on other sites More sharing options...
requinix Posted November 20, 2013 Share Posted November 20, 2013 Have you already (re)named the files? $today = date('l');That's what it uses to determine the name of the file. Check the documentation to see how to make it return a day number instead of a weekday name. Link to comment https://forums.phpfreaks.com/topic/284120-new-message-every-day/#findComment-1459274 Share on other sites More sharing options...
grucker Posted November 21, 2013 Author Share Posted November 21, 2013 On 11/20/2013 at 10:48 PM, requinix said: Have you already (re)named the files? $today = date('l');That's what it uses to determine the name of the file. Check the documentation to see how to make it return a day number instead of a weekday name. I renamed the files 1.php 2.php etc. but the else message came up. I tried the various other letters in the code you advised but the else message still came up with the name of todays day i.e. Thursday so it doesnt seem to have changed anything. I even cleared the letter from the parentheses so it was $today = date(''); and the day name still came up. Could you give more advice please. Link to comment https://forums.phpfreaks.com/topic/284120-new-message-every-day/#findComment-1459330 Share on other sites More sharing options...
cyberRobot Posted November 21, 2013 Share Posted November 21, 2013 Have you tried using a root-relative link? For example, you could try something like: $day_post = "{$_SERVER['DOCUMENT_ROOT']}/includes/days"; Of course, you may need to adapt the path which comes after the SERVER variable. More information about the SERVER variable can be found here: http://php.net/manual/en/reserved.variables.server.php Link to comment https://forums.phpfreaks.com/topic/284120-new-message-every-day/#findComment-1459358 Share on other sites More sharing options...
grucker Posted November 21, 2013 Author Share Posted November 21, 2013 On 11/21/2013 at 1:41 PM, cyberRobot said: Have you tried using a root-relative link? For example, you could try something like: $day_post = "{$_SERVER['DOCUMENT_ROOT']}/includes/days"; Of course, you may need to adapt the path which comes after the SERVER variable. More information about the SERVER variable can be found here: http://php.net/manual/en/reserved.variables.server.php Dont think its that. When I called the files monday etc. and asked for the daily message everything worked fine. Renaming the fies to 1, 2 3 etc. and calling the month day number results in error message but for the day in question. So no wiser. Link to comment https://forums.phpfreaks.com/topic/284120-new-message-every-day/#findComment-1459418 Share on other sites More sharing options...
requinix Posted November 21, 2013 Share Posted November 21, 2013 So what's your code now after the changes you made? Link to comment https://forums.phpfreaks.com/topic/284120-new-message-every-day/#findComment-1459419 Share on other sites More sharing options...
cyberRobot Posted November 21, 2013 Share Posted November 21, 2013 On 11/21/2013 at 8:15 PM, requinix said: So what's your code now after the changes you made? @grucker - When posting the code, please surround it with tags. It makes the code and the post easier to read. Link to comment https://forums.phpfreaks.com/topic/284120-new-message-every-day/#findComment-1459424 Share on other sites More sharing options...
grucker Posted November 21, 2013 Author Share Posted November 21, 2013 the files are 1 through 31 .php <?php // Change $day_images to the location of images $day_post = "includes/days"; $today = date(''); if (file_exists($day_post."/".$today.".php")) { /**echo "$day_post/".$today.".php"; **/ include("$day_post/".$today.".php"); } else { echo "No thoughts came into my head $today"; } ?> Link to comment https://forums.phpfreaks.com/topic/284120-new-message-every-day/#findComment-1459453 Share on other sites More sharing options...
cyberRobot Posted November 22, 2013 Share Posted November 22, 2013 I think the issue is that you were originally passing 'l' to the date function which gives you a value from "Sunday" through "Saturday". Have you tried "j"? $today = date('j'); That gives you the day of the month 1 to 31. Link to comment https://forums.phpfreaks.com/topic/284120-new-message-every-day/#findComment-1459455 Share on other sites More sharing options...
grucker Posted November 24, 2013 Author Share Posted November 24, 2013 On 11/22/2013 at 12:03 AM, cyberRobot said: I think the issue is that you were originally passing 'l' to the date function which gives you a value from "Sunday" through "Saturday". Have you tried "j"? $today = date('j'); That gives you the day of the month 1 to 31. Thank you ever so much that is the answer Link to comment https://forums.phpfreaks.com/topic/284120-new-message-every-day/#findComment-1459820 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.