[EMAIL PROTECTED] wrote:

> im using cfmx 6.1, xp pro
>
Oh ok.... the way CF now() was showing up looking like this "'2004-"
made me think you were on an older version of CF.

> ok when i do this
> <!--- set form variables --->
> <cfset title=trim(form.title)>
> <cfset content=trim(form.content)>
> <cfset insertDate=#CreateODBCDate(Now())#>
>
One issue you're going to find with using CreateODBC... functions
outside of a query is that CF will try to escape the single quotes that
appear in a correctly formated ODBC date/time.  You can either solve
this by using the CreateODBC... function directly in the query or stick
a PreserveSingleQuotes() function around the data in the query.  Its
probably just as easy to put the function directly into the query.

> <!--- do insert now --->
> <CFQUERY NAME="qnews" DATASOURCE="#dsn#" USERNAME="#un#" PASSWORD="#pw#">
>     INSERT INTO guide (title, content, update)
>              VALUES ('#title#', '#content#',  #insertDate#)
> </CFQUERY>
>

INSERT INTO guide (title, content, update)
VALUES ('#title#', '#content#', #now()#)

which uses the full odbc date time returned by the CF function now()
or

INSERT INTO guide (title, content, update)
VALUES ('#title#', '#content#', now())

which will use the mySQL now() function instead of CF
or

INSERT INTO guide (title, content, update)
VALUES ('#title#', '#content#', #createodbcdate(now())#)

which will sort out a valid ODBC date from the ODBC date/time returned
by now().

> i get this
>
> Error Executing Database Query.
> Syntax error or access violation: You have an error in your SQL syntax.
> Check the manual that corresponds to your MySQL server version for the
> right syntax to use near 'update) VALUES ('erwerew', 'rerrwrew w', '2004-
>

Hmmm... still missing the bit I was after.   Somewhere in the error
message, if you have debugging turned on, you should see the complete
SQL statement, rather than just the bit where things are going wrong.

Stephen
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to