RE: [PHP] Month
| From: | Brad Fuller | Date: | Mon, 19 Feb 2007 19:13:08 +0000 |
| Subject: | RE: [PHP] Month | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-249041@lists.php.net to get a copy of this message | ||
> -----Original Message-----
> From: Dan Shirah [mailto:mrsquash2@gmail.com]
> Sent: Monday, February 19, 2007 2:08 PM
> To: Brad Fuller
> Cc: Jay Blanchard; php-general
> Subject: Re: [PHP] Month
>
> Okay, when I try the sprintf I get the following error when I try to save
> my
> form
>
> Incorrect syntax near 's'.
>
> <select name="month">
> <?PHP
> for ($m=1;$m<=12;$m++) {
> $months=date('M', mktime(0, 0, 0, $m, 2));
> echo "<option value=\"sprintf('%02s',
> $m)\">$months</option>";
> }
> ?>
> </select>
I'm pretty sure you need to use double quotes on the format string.
echo "<option value=\"".sprintf("%02s",
$m)."\">$months</option>";