Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.