Probably a really simple question...

topic posted Thu, December 20, 2007 - 12:51 PM by  SMSapphire
Hey all~

So I'm really just diving in to the world of PHP and created a website for some friends that uses to insert header and footer information into the pages, plus a simple hit counter and a guestbook. I just finished a MySQL class and am interested in switching the guestbook over to PHP/MySQL, as it currently reads from, and writes to a flat text file.

So as I was setting up the initial form to populate the database, I noticed that the date kept coming up NULL, so I added the following statements:

<?php
$date = date("h:ia, F jS, Y");
?>

<p>Todays Date is: <?php date("h:ia, F jS, Y"); ?></p> <!-- Try inserting date directly -->
<p>Todays Date is: <?php $date; ?></p> <!-- Try using local variable -->

And nothing is coming up!I thought it would be a total non-issue, but I'm at a loss why something this simple wouldn't just work.

Any thoughts? Thanks for any assistance.

SMSapphire
  • Re: Probably a really simple question...

    Sun, December 23, 2007 - 1:21 PM
    << <p>Todays Date is: <?php date("h:ia, F jS, Y"); ?></p> <!-- Try inserting date directly -->
    <p>Todays Date is: <?php $date; ?></p> <!-- Try using local variable --> >>

    You're not printing anything to screen. Try:

    <?= date("h:ia, F jS, Y") ?>

    Which is short-hand for:

    <? echo date("h:ia, F jS, Y"); ?>

Recent topics in "PHP Developers"

Topic Author Replies Last Post
using dreamweavers PHP Jivatma 2 August 4, 2008
Another question about formatting date & time SMSapphire 6 June 7, 2008
phpews Satinder 0 June 4, 2008
how works with joomla ??? iShaun 1 May 22, 2008