I came up with the following piece of code for the "submit articles" page for my site's staff:
<input type="text" name="date" size="45" value="<? echo (date ("Y-m-d")); ?>">
This way the current date shows up as default in the form. The whole mish mash is processed with an INSERT query upon hitting the submit button. See below:
$sql = "INSERT INTO reviews SET ".
"title='$title', " .
"content='$content', " .
"microcontent='$microcontent', " .
"requirements='$requirements', " .
"date='$date', " .
"releasedate='$releasedate', " .
Seems OK to me, but when I check the front end page, the date that shows up is 0000-00-00
The code I use to show the date is
What have I done wrong?
The quotes work in pairs and when an initial double quote is used, it only applies until the next occurance of the double quote so in line 5 you have "text", then "date", then "45", then "<? echo (date (", then ")); ?>"
so this causes the Y-m-d to not appear in quotes.
i would try to use the single quotes in the following manner '<? echo(date("Y-m-d"));?>'
i had a similar problem about a month ago and backed completely away from it and used this
then i just move Today around. but what you are doing is more elegant.
hope this helps.
i looked at my response from earlier and may be about a mile off. considering the quotes but look also at your line:
and consider that it might need to be:
I found that typo too, thanks.
I solved the quotes problem like this:
<input type="text" name="date" size="45" value=<? echo ("\"" . date ("Y-m-d") . "\""); ?>>