Rush_2112
asked on
cf page ignoring cfparam?
I have a form on one page, which submits to a second page.
In the form, I have 5 text boxes, named hours1, hours2, hours3, hours4, hours5.
I have this at the top of the second page, to handle blank fields:
<cfparam name="form.hours1"default= "0">
<cfparam name="form.hours2" default="0">
<cfparam name="form.hours3" default="0">
<cfparam name="form.hours4" default="0">
<cfparam name="form.hours5" default="0">
Here's my cfquery to insert:
<cfquery name="inserttimeoff" datasource="data">
INSERT INTO timeoff
(DateEntered,dayone,daytwo ,daythree, dayfour,da yfive,comm ents,Emplo yeeID,Mana gerID,hour s1,hours2, hours3,hou rs4,hours5 )
VALUES (<cfqueryparam cfsqltype="cf_sql_date" value="#form.DateEntered#" >,
<cfqueryparam cfsqltype="cf_sql_date" value="#form.dayone#">,
<cfqueryparam cfsqltype="cf_sql_date" value="#form.daytwo#">,
<cfqueryparam cfsqltype="cf_sql_date" value="#form.daythree#">,
<cfqueryparam cfsqltype="cf_sql_date" value="#form.dayfour#">,
<cfqueryparam cfsqltype="cf_sql_date" value="#form.dayfive#">,
<cfqueryparam cfsqltype="cf_sql_longvarc har" value="#form.comments#">,
<cfqueryparam cfsqltype="cf_sql_varchar" value="#form.EmployeeID#"> ,
<cfqueryparam cfsqltype="cf_sql_varchar" value="#form.ManagerID#">,
<cfqueryparam value="#form.hours1#" cfsqltype="cf_sql_integer" >,
<cfqueryparam value="#form.hours2#" cfsqltype="cf_sql_integer" >,
<cfqueryparam value="#form.hours3#" cfsqltype="cf_sql_integer" >,
<cfqueryparam value="#form.hours4#" cfsqltype="cf_sql_integer" >,
<cfqueryparam value="#form.hours5#" cfsqltype="cf_sql_integer" >)
</cfquery>
I get the following error:
Invalid data '' for CFSQLTYPE CF_SQL_INTEGER. on line 32 which is:
32 : <cfqueryparam value="#form.hours5#" cfsqltype="cf_sql_integer" >)
A CFdump shows this as the values of the hours1-hours5 fields:
HOURS1 8
HOURS2 [empty string]
HOURS3 [empty string]
HOURS4 [empty string]
HOURS5 [empty string]
(I typed in 8, left the rest blank)
So why that error? Why is the code ignoring the parameters I set in the beginning of the second page?
Need help! Thanks
In the form, I have 5 text boxes, named hours1, hours2, hours3, hours4, hours5.
I have this at the top of the second page, to handle blank fields:
<cfparam name="form.hours1"default=
<cfparam name="form.hours2" default="0">
<cfparam name="form.hours3" default="0">
<cfparam name="form.hours4" default="0">
<cfparam name="form.hours5" default="0">
Here's my cfquery to insert:
<cfquery name="inserttimeoff" datasource="data">
INSERT INTO timeoff
(DateEntered,dayone,daytwo
VALUES (<cfqueryparam cfsqltype="cf_sql_date" value="#form.DateEntered#"
<cfqueryparam cfsqltype="cf_sql_date" value="#form.dayone#">,
<cfqueryparam cfsqltype="cf_sql_date" value="#form.daytwo#">,
<cfqueryparam cfsqltype="cf_sql_date" value="#form.daythree#">,
<cfqueryparam cfsqltype="cf_sql_date" value="#form.dayfour#">,
<cfqueryparam cfsqltype="cf_sql_date" value="#form.dayfive#">,
<cfqueryparam cfsqltype="cf_sql_longvarc
<cfqueryparam cfsqltype="cf_sql_varchar"
<cfqueryparam cfsqltype="cf_sql_varchar"
<cfqueryparam value="#form.hours1#" cfsqltype="cf_sql_integer"
<cfqueryparam value="#form.hours2#" cfsqltype="cf_sql_integer"
<cfqueryparam value="#form.hours3#" cfsqltype="cf_sql_integer"
<cfqueryparam value="#form.hours4#" cfsqltype="cf_sql_integer"
<cfqueryparam value="#form.hours5#" cfsqltype="cf_sql_integer"
</cfquery>
I get the following error:
Invalid data '' for CFSQLTYPE CF_SQL_INTEGER. on line 32 which is:
32 : <cfqueryparam value="#form.hours5#" cfsqltype="cf_sql_integer"
A CFdump shows this as the values of the hours1-hours5 fields:
HOURS1 8
HOURS2 [empty string]
HOURS3 [empty string]
HOURS4 [empty string]
HOURS5 [empty string]
(I typed in 8, left the rest blank)
So why that error? Why is the code ignoring the parameters I set in the beginning of the second page?
Need help! Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
... lather, rinse, repeat for all of the hour fields.
ASKER
yup, that did it!! I forgot all about that... thanks!
ASKER
perfect!