473,396 Members | 2,050 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

coldfusion mysql error

Anyone see what I'm doing wrong?
Here's the form field:
Expand|Select|Wrap|Line Numbers
  1. <input type="hidden" name="date" value="<cfoutput>#DateFormat(Now(), "MM/DD/YY")# At #TimeFormat(Now(),"hh:mm tt")#</cfoutput>" size="32">
  2.  
Here's the sql insert:
Expand|Select|Wrap|Line Numbers
  1.   <cfif IsDefined("FORM.date") AND #FORM.date# NEQ "">
  2.     '#FORM.date#'
  3.       <cfelse>
  4.     NULL
  5.   </cfif>
  6.  
,

(NOTE: I've tried with and without the single quotes around #FORM.date#

Here's the error.

Expand|Select|Wrap|Line Numbers
  1. 14 : <cfif IsDefined("FORM.MM_InsertRecord") AND FORM.MM_InsertRecord EQ "form1">
  2. 15 :   
  3. 16 :   <cfquery datasource="">
  4. 17 :     INSERT INTO scoretable (puzzleid, studentid, pointpossible, score, time, date, percentage)
  5. 18 :     VALUES (
  6.  
  7.  
--------------------------------------------------------------------------------

Expand|Select|Wrap|Line Numbers
  1. SQL    INSERT INTO scoretable (puzzleid, studentid, pointpossible, score, time, date, percentage) VALUES ( NULL , 111 , 9 , 9 , 23 , '12/16/06 At 12:47 AM' , 100% )  
  2. DATASOURCE    
  3. VENDORERRORCODE   1064 
  4. SQLSTATE   42000
Dec 16 '06 #1
3 6785
Try the following code:
I think you have error while inserting the date
do you have separate field for date and time?

Expand|Select|Wrap|Line Numbers
  1. <form action="" method="post">
  2. <input type="hidden" name="date" value="<cfoutput>#DateFormat(Now(), "MM/DD/YY")#</cfoutput>">
  3. <input type="hidden" name="time" value="<cfoutput>#TimeFormat(Now(),"hh:mm tt")#</cfoutput>">
  4. </form>
  5. <cfif IsDefined("FORM.date") AND #FORM.date# NEQ "">
  6. '#FORM.date#'
  7. <cfelse>
  8. NULL
  9. </cfif>
  10.  
  11. <cfif IsDefined("FORM.MM_InsertRecord") AND FORM.MM_InsertRecord EQ "form1">
  12. <cfquery datasource="">
  13. INSERT INTO scoretable (puzzleid, studentid, pointpossible, score, time, date, percentage)
  14. VALUES (NULL , 111 , 9 , 9 , 23 ,'#form.time#','#form.date#',100% )
  15. </cfquery>
  16. </cfif>
Dec 25 '06 #2
acoder
16,027 Expert Mod 8TB
Anyone see what I'm doing wrong?
Here's the form field:
<input type="hidden" name="date" value="<cfoutput>#DateFormat(Now(), "MM/DD/YY")# At #TimeFormat(Now(),"hh:mm tt")#</cfoutput>" size="32">

Here's the sql insert:
<cfif IsDefined("FORM.date") AND #FORM.date# NEQ "">
'#FORM.date#'
<cfelse>
NULL
</cfif>
,

(NOTE: I've tried with and without the single quotes around #FORM.date#

Here's the error.

14 : <cfif IsDefined("FORM.MM_InsertRecord") AND FORM.MM_InsertRecord EQ "form1">
15 :
16 : <cfquery datasource="">
17 : INSERT INTO scoretable (puzzleid, studentid, pointpossible, score, time, date, percentage)
18 : VALUES (



--------------------------------------------------------------------------------

SQL INSERT INTO scoretable (puzzleid, studentid, pointpossible, score, time, date, percentage) VALUES ( NULL , 111 , 9 , 9 , 23 , '12/16/06 At 12:47 AM' , 100% )
DATASOURCE
VENDORERRORCODE 1064
SQLSTATE 42000
A number of points:

1. Why are you passing the date as a hidden field if you're using today's date anyway. Just use the code on the page that contains the query.
2. Date should be in the recognised format for the mysql database. I doubt that the format you are using is correct. Search for acceptable date formats. Remove the 'At' - surely that is not needed.
3. In you query, you have Null for puzzleid which is definitely incorrect - you can't have a null value for a primary key.
4. For time, you have a value of 23. what does that mean?
5. As I explained, the date is of the wrong format.
6. The percentage sign % holds special significance in SQL. Just use 100 instead.
7. Perhaps, you could consider changing your database, e.g. no need to store percentage because it can easily be calculated. also, the puzzle table will contain the pointpossible value which you can easily obtain so no need to store that in the scoretable either.
8. Date/time should be one field.

Quite a few things there for you to think over..
Dec 26 '06 #3
RedSon
5,000 Expert 4TB
Next time, please remember that this is a website so posting sensitive information about your company or posting code/text that can be easily googled by your company managers is probably not a good idea.
Jan 11 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

60
by: English Teacher | last post by:
Which would be more useful to learn, PHP or COLDFUSION? I know Coldfusion is popular in the work force. Is PHP? Thanks!
1
by: asnyder131 | last post by:
I'm a newby here as well as to mysql and coldfusion. I'm a business owner who had previously designed my own relational database system for my company (smartware) and used it sucessfully for many...
3
acoder
by: acoder | last post by:
How to Upload a File in Coldfusion Use the cffile tag for uploading files to the server. Note that allowing people to upload files is fraught with danger and only trusted users should be...
7
acoder
by: acoder | last post by:
This page will link to a number of tutorials. Coldfusion Language Coldfusion Variables Using Coldfusion Variables Coldfusion Image Gallery How to upload a file in Coldfusion How to send...
3
by: jesmi | last post by:
how to connect coldfusion and access? while connecting like mysql gave following error: This applet displays a file-tree of the server to enable the user to browse its contents. Your browser is...
3
by: sj3vans | last post by:
I'm trying to integrate a ColdFusion application with a webAPI provided by another company to access their services. Their requirements are that requests should be generated using standard HTTP...
1
by: marcnz | last post by:
I have been charged of creating a coldfusion web site for our company. Our database has a ms sql 2005 backend and ms access frontend. Almost all tables are linked tables with the SQL database,...
2
by: quest007 | last post by:
Hi! I have configured IIS for coldfusion and when I access my coldfusion site through localhost, the pages are served as required. But if i ty to access it from a remote machine by specifying the IP...
2
by: joshMcwatters | last post by:
Hi, I'm trying us mySql user defined variables in a cfquery tag, but I keep getting an error. I know the statement should work because I've tested it a mySQL GUI without problems. ...
7
by: SAL | last post by:
Hopefully someone will have a clue as to what is happening here. In our office, we have both ColdFusion and ASP.NET applications. One of our new developers has been installing ColdFusion 8 on the...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.