On Thu, Apr 19, 2012 at 2:17 PM, Steven Staples <sstap...@mnsi.net> wrote:
>> -----Original Message-----
>> From: Silvio Siefke [mailto:siefke_lis...@web.de]
>> Sent: April 19, 2012 3:11 PM
>> To: php-general@lists.php.net
>> Subject: Re: [PHP] SqLite INSERT want not write
>>
>> On Thu, 19 Apr 2012 14:57:04 -0400
>> "Steven Staples" <sstap...@mnsi.net> wrote:
>>
>> > I think all you had to do was change this line: (line 27 in the
>> > original
>> > paste)
>> > $sql = 'INSERT INTO bloggen (date, autor, title, teaser, content)
>> >       VALUES ('' . date( 'Y-m-s H:i:s', time() ) . '', :autor, :title,
>> > :teaser, :content);';
>> >
>> > To this:
>> > $sql = "INSERT INTO bloggen (date, autor, title, teaser, content)
>> >       VALUES ('' . date( 'Y-m-s H:i:s', time() ) . '', :autor, :title,
>> > :teaser, :content);";
>>
>> Thats end with:
>> PDOException: SQLSTATE[HY000]: General error: 1 near "(": syntax error
>>
>> I has changed what say Stuart, no Sytax errors but in the database nothing
>> will write.
>>
>> Regards
>> Silvio
>>
>
> Ok, so I was wrong... ;)   it does happen
>
> Try this:
> $sql = "INSERT INTO bloggen (date, autor, title, teaser, content)
>       VALUES ('" . date('Y-m-d H:i:s') . "', :autor, :title,
>  :teaser, :content);";
>
> Or
> $sql = "INSERT INTO bloggen (date, autor, title, teaser, content)
>       VALUES (NOW(), :autor, :title, :teaser, :content);";
>
>
> The first example, you don't need the time(), and you had the date format
> wrong...
> The second example, uses the NOW() time, which is the timestamp for sql
>
> Maybe this time I will get it right ;) -- its been a long day, and it is
> only 1/2 done
>
> Steve
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

For sqlite, you can specify the current datetime with just "now".

So perhaps the insert statement could be simplified to:

$sql = "INSERT INTO bloggen (date, autor, title, teaser, content)
VALUES(now, :autor, :title, :teaser, :content);";

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to