error on insert record form
hi,
i've created million insert record forms without problems, reason keep getting same error when i've tried creating form on different pages, different recordsets , whatever else can think of, keep getting error (here's error , code):
you have error in sql syntax; check manual corresponds mysql server version right syntax use near 'where, when, whotocontact) values ( 2 , 'stay' , 'mikew' , 'd' , 'h' ' @ line 1
the error occurred in c:\coldfusion9\wwwroot\mymindsnotrightcopy\supportgroupformneedsinclude.cfm: line 47
45 : , <cfif isdefined("form.whotocontact") , #form.whotocontact# neq "">
46 : <cfqueryparam value="#form.whotocontact#" cfsqltype="cf_sql_clob" maxlength="2147483647">
47 : <cfelse>
48 : ''
49 : </cfif>
<cfset currentpage=getfilefrompath(getbasetemplatepath())>
<cfif isdefined("form.mm_insertrecord") , form.mm_insertrecord eq "form1">
<cfquery datasource="mymindsnotrighttest">
insert supportgroups (supportgroup_id, supportgroup_name, user_id, username, description, howlong, state, where, when, whotocontact)
values (<cfif isdefined("form.supportgroup_id") , #form.supportgroup_id# neq "">
<cfqueryparam value="#form.supportgroup_id#" cfsqltype="cf_sql_numeric">
<cfelse>
null
</cfif>
, <cfif isdefined("form.supportgroup_name") , #form.supportgroup_name# neq "">
<cfqueryparam value="#form.supportgroup_name#" cfsqltype="cf_sql_clob" maxlength="65535">
<cfelse>
''
</cfif>
, <cfif isdefined("form.user_id") , #form.user_id# neq "">
<cfqueryparam value="#form.user_id#" cfsqltype="cf_sql_numeric">
<cfelse>
null
</cfif>
, <cfif isdefined("form.username") , #form.username# neq "">
<cfqueryparam value="#form.username#" cfsqltype="cf_sql_clob" maxlength="65535">
<cfelse>
''
</cfif>
, <cfif isdefined("form.description") , #form.description# neq "">
<cfqueryparam value="#form.description#" cfsqltype="cf_sql_clob" maxlength="9999">
<cfelse>
''
</cfif>
, <cfif isdefined("form.howlong") , #form.howlong# neq "">
<cfqueryparam value="#form.howlong#" cfsqltype="cf_sql_clob" maxlength="65535">
<cfelse>
''
</cfif>
, <cfif isdefined("form.state") , #form.state# neq "">
<cfqueryparam value="#form.state#" cfsqltype="cf_sql_clob" maxlength="65535">
<cfelse>
''
</cfif>
, <cfif isdefined("form.where") , #form.where# neq "">
<cfqueryparam value="#form.where#" cfsqltype="cf_sql_clob" maxlength="2147483647">
<cfelse>
''
</cfif>
, <cfif isdefined("form.when") , #form.when# neq "">
<cfqueryparam value="#form.when#" cfsqltype="cf_sql_clob" maxlength="2147483647">
<cfelse>
''
</cfif>
, <cfif isdefined("form.whotocontact") , #form.whotocontact# neq "">
<cfqueryparam value="#form.whotocontact#" cfsqltype="cf_sql_clob" maxlength="9999">
<cfelse>
''
</cfif>
)
</cfquery>
<cflocation url="supportgroup_details.cfm?supportgroup_id=#form.supportgroup_id#">
</cfif>
<cfquery name="rssupportgroups" datasource="mymindsnotrighttest">
select *
from supportgroups
</cfquery>
<cfquery name="rsstates" datasource="mymindsnotrighttest">
select *
from states
order "state" asc
</cfquery>
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<title>my minds not right -- online support group</title>
<link rel="stylesheet" type="text/css" href="html/style.css">
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<style type="text/css">
.blogcontent {
font-size: 11pt;
font-family: tahoma, geneva, sans-serif;
}
.comments {
font-family: tahoma, geneva, sans-serif;
font-size: 12px;
font-weight: bold;
text-decoration: underline;
text-align: right;
color: #246494;
}
.featuredbloglist {
font-family: tahoma, geneva, sans-serif;
font-size: 11px;
}
.featuredbloglistheader {
font-family: tahoma, geneva, sans-serif;
font-size: 12px;
font-weight: bold;
color: #246494;
/* [disabled]border-bottom-style: solid; */
}
.blogdate {
font-size: 9pt;
font-style: italic;
font-family: tahoma, geneva, sans-serif;
}
.bloguserandwho {
font-size: 10pt;
font-style: normal;
font-family: tahoma, geneva, sans-serif;
}
.redlink {
font-family: tahoma, geneva, sans-serif;
color: #f00;
font-size: 10pt;
}
.blogtitle {
font-size: 16px;
font-weight: bold;
font-family: tahoma, geneva, sans-serif;
color: #246494;
}
.quotestyle {
font-family: verdana, geneva, sans-serif;
font-size: 11pt;
font-style: italic;
color: #000;
}
.justified {
text-align: justify;
}
</style>
<script type="text/javascript">
function mm_swapimgrestore() { //v3.0
var i,x,a=document.mm_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.osrc;i++) x.src=x.osrc;
}
function mm_preloadimages() { //v3.0
var d=document; if(d.images){ if(!d.mm_p) d.mm_p=new array();
var i,j=d.mm_p.length,a=mm_preloadimages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexof("#")!=0){ d.mm_p[j]=new image; d.mm_p[j++].src=a[i];}}
}
function mm_findobj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexof("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=mm_findobj(n,d.layers[i].document);
if(!x && d.getelementbyid) x=d.getelementbyid(n); return x;
}
function mm_swapimage() { //v3.0
var i,j=0,x,a=mm_swapimage.arguments; document.mm_sr=new array; for(i=0;i<(a.length-2);i+=3)
if ((x=mm_findobj(a[i]))!=null){document.mm_sr[j++]=x; if(!x.osrc) x.osrc=x.src; x.src=a[i+2];}
}
</script>
</head>
<body bgcolor="#ffffff" leftmargin=0 topmargin=0 marginwidth="0" marginheight="0" onload="mm_preloadimages('images/about_invert.jpg','images/discussion_invert.jpg','images /family_invert.jpg','images/askquestion_invert.jpg','images/newsletters_invert.jpg','image s/home_invert.jpg')">
<table border="0" cellspacing="0" cellpadding="0" width="100%" height="100%">
<tr>
<td width="50%" background="images/bg.gif" valign="top"><img src="images/px1.gif" width="1" height="1" alt="" border="0"></td>
<td valign="top" background="images/bg_left.gif"><img src="images/bg_left.gif" alt="" width="17" height="16" border="0">
</td>
<td valign="top">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="780"></td>
<td width="100%">
<table width="780" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><img src="images/logo01new.jpg" width="510" height="126"><img src="images/logo02clean.jpg" width="270" height="126" border="0"></td>
</tr>
<tr>
<cfinclude template="topbar.cfm">
</tr>
</table>
</td>
</tr>
</table>
<cfinclude template="sidebar.cfm">
<p class="left">
<cfinclude template="includes/sidebarlinks.cfm">
<br>
</p>
<!-- /left -->
</td>
<td rowspan="2" width="100%">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>
<td background="images/fon_right.gif"><img src="images/featuredblogs.jpg" width="322" height="35" alt="" border="0"></td>
<td bgcolor="#b9b9b9"><img src="images/px1.gif" width="1" height="1" alt="" border="0"></td>
<td background="images/fon_right.gif"> </td>
<td bgcolor="#b9b9b9"><img src="images/px1.gif" width="1" height="1" alt="" border="0"></td>
<td valign="top" rowspan="2" width="100%">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="2"><img src="images/2_f_2.gif" width="2" height="35"></td>
<td background="images/2_f_2_fon.gif" width="100%"><img src="images/topend.jpg" width="28" height="36"></td>
</tr>
</table></td>
</tr>
<tr valign="top">
<td background="images/fon01.gif" style="background-position: top; background-repeat: repeat-x; font-size: 9px; font-family: tahoma, geneva, sans-serif; color: #000;"><table border="0" cellspacing="0" cellpadding="0" width="90%" background="" align="center">
<tr valign="top">
<td align="left"><h6><br>
</h6>
<table width="97%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="44%"><span class="blogtitle">support groups:</span></td>
<td width="56%" align="right" class="redlink"><strong>start group/add group list</strong></td>
</tr>
</table>
<p class="blogtitle"> </p>
<p class="blogcontent"> </p>
<p class="blogtitle"> </p>
<p class="blogtitle"> </p></td>
</tr>
</table>
</td>
<td bgcolor="#b9b9b9"><img src="images/px1.gif" width="1" height="1" alt="" border="0"></td>
<td background="images/fon01.gif" style="background-position: top; background-repeat: repeat-x;">
<br></td>
<td bgcolor="#b9b9b9"><img src="images/px1.gif" width="1" height="1" alt="" border="0"></td>
</tr>
<tr>
<td background="images/fon02.gif" colspan="3"><img src="images/blogoftheweek.jpg" width="563" height="43" alt="" border="0"></td>
<td bgcolor="#b9b9b9"><img src="images/px1.gif" width="1" height="1" alt="" border="0"></td>
<td background="images/fon_right.gif" width="100%"><img src="images/px1.gif" width="1" height="1" alt="" border="0"></td>
</tr>
<tr>
<td colspan="3" align="left" valign="top"><blockquote>
<p> </p>
<p> </p>
<p> </p>
<form method="post" name="form1" action="<cfoutput>#currentpage#</cfoutput>">
<table align="center">
<tr valign="baseline">
<td nowrap align="right">supportgroup_name:</td>
<td><input type="text" name="supportgroup_name" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right" valign="top">description:</td>
<td><textarea name="description" cols="50" rows="5"></textarea></td>
</tr>
<tr valign="baseline">
<td nowrap align="right" valign="top">howlong:</td>
<td><textarea name="howlong" cols="50" rows="5"></textarea></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">state:</td>
<td><input type="text" name="state" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right" valign="top">where:</td>
<td><textarea name="where" cols="50" rows="5"></textarea></td>
</tr>
<tr valign="baseline">
<td nowrap align="right" valign="top">when:</td>
<td><textarea name="when" cols="50" rows="5"></textarea></td>
</tr>
<tr valign="baseline">
<td nowrap align="right" valign="top">whotocontact:</td>
<td><textarea name="whotocontact" cols="50" rows="5"></textarea></td>
</tr>
<tr valign="baseline">
<td nowrap align="right"> </td>
<td><input type="submit" value="insert record"></td>
</tr>
</table>
<input type="hidden" name="supportgroup_id" value="<cfoutput>#incrementvalue(rssupportgroups.recordcount)#</cfoutput>">
<input type="hidden" name="user_id" value="<cfoutput>#rsgetuserid.user_id#</cfoutput>">
<input type="hidden" name="username" value="<cfoutput>#session.mm_username#</cfoutput>">
<input type="hidden" name="mm_insertrecord" value="form1">
</form>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
</blockquote>
<p> </p>
<p> </p>
<p> </p>
<p> </p></td>
<td bgcolor="#b9b9b9"><img src="images/px1.gif" width="1" height="1" alt="" border="0"></td>
<td>
<div align="left"><img src="images/px1.gif" width="1" height="1" alt="" border="0"></div>
</td>
</tr>
</table>
</td>
</tr>
<tr bgcolor="#246494">
<td valign="bottom">
<table border="0" cellspacing="0" cellpadding="0" width="188" height="67" background="images/left_bot.gif">
<tr>
<td valign="bottom">
<p class="left" style="margin-bottom: 0px; margin-left: 20px;">copyright
©2010<br>
mymindsnotright.com<br>
rights reserved</p>
</td>
</tr>
</table>
</td>
</tr>
</table>
<table border="0" cellspacing="0" cellpadding="0" width="100%" height="77" background="images/fon_bot.gif">
<tr>
<td valign="top" width="780">
<cfinclude template="bottombar.cfm"></td>
<td><img src="images/px1.gif" width="1" height="1" alt="" border="0"></td>
</tr>
<tr>
<td><img src="images/px1.gif" width="780" height="1" alt="" border="0"></td>
<td><img src="images/px1.gif" width="1" height="1" alt="" border="0"></td>
</tr>
</table>
</td>
<td valign="bottom" background="images/bg_right.gif"><img src="images/bg_right.gif" alt="" width="17" height="16" border="0"></td>
<td width="50%" background="images/bg.gif" valign="top"><img src="images/px1.gif" width="1" height="1" alt="" border="0"></td>
</tr>
</table>
</body>
</html>
wycks wrote:
insert supportgroups (supportgroup_id, supportgroup_name, user_id,
username, description, howlong, state, where, when, whotocontact)
i stopped looking @ point.... can see error. "where" reserved word in sql. can't use column name, @ least not without escaping it. database trying start clause when sees command there, , goes not right.
either escape column name or change name of column not sql command word.
More discussions in ColdFusion
adobe
Comments
Post a Comment