Hello;
I am making a small security app for a log in feature. I have
everything working, but when I try to post to the DB and leave a
form field blank, it throws an error. I am placing my query code
and then the 2 errors I am getting:
Query:
<cfquery datasource="#APPLICATION.dataSource#">
INSERT INTO Bliplist
(reject, HTTP_USER_AGENT)
VALUES
(<cfqueryparam cfsqltype="cf_sql_varchar"
value="#form.rejip#">,
<cfqueryparam cfsqltype="cf_sql_longvarchar"
value="#form.browser#">)
</cfquery>
<cflocation url="blist.cfm">
Error:
Error Executing Database Query.
[Macromedia][SequeLink JDBC Driver][ODBC
Socket][Microsoft][ODBC Microsoft Access Driver] Field
'Bliplist.HTTP_USER_AGENT' cannot be a zero-length string.
The error occurred in
C:\Websites\4npp8b\admin\trac\bl-action.cfm: line 28
26 : (<cfqueryparam cfsqltype="cf_sql_varchar"
value="#form.rejip#">,
27 : <!--- <cfif HTTP_USER_AGENT is true> --->
28 : <cfqueryparam cfsqltype="cf_sql_longvarchar"
value="#form.browser#">)
29 : <!--- </cfif> --->
30 : </cfquery>
--------------------------------------------------------------------------------
SQLSTATE HY000
SQL INSERT INTO Bliplist (reject, HTTP_USER_AGENT) VALUES (
(param 1) , (param 2) )
VENDORERRORCODE -3702
So I added the code to check if the field was true, and I get
this error: (here is the cfif and error:
<cfif HTTP_USER_AGENT is true>
<cfqueryparam cfsqltype="cf_sql_longvarchar"
value="#form.browser#">)
</cfif>
Error message:
Error Executing Database Query.
[Macromedia][SequeLink JDBC Driver][ODBC
Socket][Microsoft][ODBC Microsoft Access Driver] Syntax error in
INSERT INTO statement.
The error occurred in
C:\Websites\4npp8b\admin\trac\bl-action.cfm: line 28
26 : (<cfqueryparam cfsqltype="cf_sql_varchar"
value="#form.rejip#">,
27 : <cfif HTTP_USER_AGENT is true>
28 : <cfqueryparam cfsqltype="cf_sql_longvarchar"
value="#form.browser#">)
29 : </cfif>
30 : </cfquery>
--------------------------------------------------------------------------------
SQLSTATE 42000
SQL INSERT INTO Bliplist (reject, HTTP_USER_AGENT) VALUES (
(param 1) ,
VENDORERRORCODE -3502
What am I doing wrong, and how do I fix it? I also have an
update query on this and that throws the same error is there is a
blank form field, Kind of lost here. How do I allow 0 length?
Thank you.
CFmonger