|
Posted by Chris Hope on 08/03/06 21:36
walterbyrd wrote:
>
> Peter Boosten wrote:
>
>>
>> now()
>>
>
> According to php.net: "Sorry, but the function now is not in the
> online manual. "
>
> Here is the actual code:
>
> This *will* work:
>
> mysql_query("INSERT INTO inventory (item_num, location, quantity,
> date_modified) VALUES($row[0], 'FLR', $row[1], '2006-08-03')")
>
>
> This will *not* work:
>
> $today = trim(date("Y-m-d"));
> . . . .
> mysql_query("INSERT INTO inventory (item_num, location, quantity,
> date_modified) VALUES($row[0], 'FLR', $row[1], $today)")
>
> Note: the only thing in the second example that will not is the date.
> It always comes out as: "0000-00-00". I have tried the date function
> with and without the trim().
>
> I have also tried the time() function, that didn't work either.
You need quotes around the date:
mysql_query("INSERT INTO inventory (item_num, location, quantity,
date_modified) VALUES($row[0], 'FLR', $row[1], '$today')")
or realise that now() is a SQL function and do:
mysql_query("INSERT INTO inventory (item_num, location, quantity,
date_modified) VALUES($row[0], 'FLR', $row[1], now())")
--
Chris Hope | www.electrictoolbox.com | www.linuxcdmall.com
Navigation:
[Reply to this message]
|