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
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...
Thu, December 20, 2007 - 1:14 PMfor printing info straight out like that i'd use
<?=$date?>
or
<?php echo $date?> -
-
Re: Probably a really simple question...
Thu, December 20, 2007 - 1:34 PMyes you have to use a statement with the var... in this case to print it you would probably want to use echo, but other statements might include print or print_r().
-
-
Re: Probably a really simple question...
Fri, December 21, 2007 - 7:51 PM$t->assign('_date_format', $_smarty_date_format); -
-
Re: Probably a really simple question...
Sat, December 22, 2007 - 4:25 PMUmm thats great but exactly what type of object is $t? thie new time/date object or something else? Also whats with the allusion to smarty? is this smarty specific templating code? -
-
Re: Probably a really simple question...
Sun, December 23, 2007 - 1:22 PM<< is this smarty specific templating code? >>
Yes. And for a unique environment.
-
-
-
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"); ?>