adamriley Posted March 28, 2010 Share Posted March 28, 2010 Before you say i have tested it and it does not work is it the coding ? <?php require_once($_SERVER['DOCUMENT_ROOT'].'/other/includes/main.php'); // get varibles needed to display if ($date == '28' && $month == 'mar'){ // ($DATE_TIME IS THE 1st one in file) /* CLOSE PHP HERE BECAUSE WE WANT TO OUTPUT HTML */ ?> <H2>Homepage</h2> <?php }else{ /* OPEN PHP FOR THE ELSE THEN CLOSE IT FOR HTML AGAIN */ ?> <h2>not time yet</h2> <?php } // OPEN PHP AGAIN FOR THE CLOSING BRACE ?> Main.php <?php $date = date("j"); // date | e.g 28 $month = date("M"); // month e.g mar $Year = date("Y"); // Year e.g 2010 $hour_min_sec = date("G:i:s") // time | e.g 18:21:30 24 hour ?> It shows <h2>not time yet</h2> even though it is 28 of the 3rd month Quote Link to comment https://forums.phpfreaks.com/topic/196790-is-this-right/ Share on other sites More sharing options...
PFMaBiSmAd Posted March 28, 2010 Share Posted March 28, 2010 Without seeing the code that sets $date and $month and seeing exactly what values are in them at the time the posted code executes, it is impossible to tell you why the code is not working. Does $month contain exactly 'mar' or is it 'Mar' or is it the month number 3? Edit to your edit: Please read the documentation for whatever you are doing in programming. It is simply impossible to write code that works without knowing (or looking up) what a function does. Quote Link to comment https://forums.phpfreaks.com/topic/196790-is-this-right/#findComment-1033055 Share on other sites More sharing options...
mattal999 Posted March 28, 2010 Share Posted March 28, 2010 $month will contain Mar, not mar. Read the manual for the date() function. Quote Link to comment https://forums.phpfreaks.com/topic/196790-is-this-right/#findComment-1033057 Share on other sites More sharing options...
adamriley Posted March 28, 2010 Author Share Posted March 28, 2010 Thanks it now works Quote Link to comment https://forums.phpfreaks.com/topic/196790-is-this-right/#findComment-1033060 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.