Jump to content

Is this right


adamriley

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/196790-is-this-right/
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/196790-is-this-right/#findComment-1033055
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.