Re: SqLite INSERT want not write

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Apr 19, 2012 at 2:17 PM, Steven Staples <sstaples@xxxxxxxx> wrote:
>> -----Original Message-----
>> From: Silvio Siefke [mailto:siefke_listen@xxxxxx]
>> Sent: April 19, 2012 3:11 PM
>> To: php-general@xxxxxxxxxxxxx
>> Subject: Re:  SqLite INSERT want not write
>>
>> On Thu, 19 Apr 2012 14:57:04 -0400
>> "Steven Staples" <sstaples@xxxxxxxx> 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




[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux