John is the type on the database for the date "DateTime"

Also it is a very good idea to use cfqueryparam for every item you are  
inserting into he database.

Paul..


On Aug 16, 2009, at 7:50 PM, John Barrett wrote:

>
>> It's usually not a good idea to use function names as variable names.
>> Date is a function in almost every language.  URL is a function in
>> quite a few.  So I would rename both of those variables.
>>
>>
>>> John
>
> Thanks Maureen:)
>
> I just changed the URL field to webSite.
> However, the form is no longer working.
>
> Is it really this hard to write a date to a database? I don't care  
> about the format.
> To write a date to a cfm page:
> <cfset date_entered="#CreateODBCDate(Now())#">
> <cfoutput>#date_entered#</cfoutput>
> out put on the page is - {d '2009-08-16'}
>
> when I try to do this in a cfquery
> <cfset date_entered="#CreateODBCDateTime(Now())#">
>
> <!--- Insert tip into the database --->
>                <cfquery datasource="#REQUEST.dataSource#">
>                  INSERT INTO test(text,webSite,desc,cat,date_entered)
>                   
> VALUES 
> ('#FORM.text#','#FORM.webSite#','#FORM.desc#','health',#date_entered#)
>                </cfquery>
>
> it does not seem to work.
>
> I would think that writing a date to a database is so common, but I  
> can't find any examples in the docs, unless I am missing something.
>
> really need to figure this out, and I have been trying for 2 days now.
> I get this error (de bugging is turned on):
> Error Executing Database Query.
>
> 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 'desc,cat,date_entered) VALUES('CF Talk','http:// 
> www.houseoffus' at line 1
>
> The error occurred in /Users/johnbarrett/Sites/FoodSystems/admin/ 
> Test/testing_action.cfm: line 6
> 4 :                 <cfquery datasource="#REQUEST.dataSource#">
> 5 :                   INSERT INTO  
> test(text,webSite,desc,cat,date_entered)
> 6 :                    
> VALUES 
> ('#FORM.text#','#FORM.webSite#','#FORM.desc#','health',#date_entered#)
> 7 :                 </cfquery>
> 8 :
> SQLSTATE        42000
> SQL      INSERT INTO test(text,webSite,desc,cat,date_entered)  
> VALUES('CF Talk','http://www.houseoffusion.com','a place to help  
> with your CF Questions','health',{ts '2009-08-16 13:53:39'})
>
>
>
>
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-newbie/message.cfm/messageid:4711
Subscription: http://www.houseoffusion.com/groups/cf-newbie/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.15

Reply via email to