Thread: CF noob help

    #1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2009
    Posts
    2
    Rep Power
    0

    Angry CF noob help


    I am trying to insert records into an access database table but I am having problems. From the error it seems like I have my column names wrong but i have racked my brain looking at the code and I am 100% positive that I have the column names correct. Here is my script

    Code:
    <cfif isDefined("person")>
    	<!--- check settings --->
    	<cfquery datasource="#dsn#" name="getSettings">
    	select activeComments, notifyComments, notifyEmail
    	from settings
    	where settingID = 1
    	</cfquery>
    	
    	<!--- strip out html and special characters --->
    	<cfset person = HTMLEditFormat(RemoveHTML(person))>
    	<cfset email = HTMLEditFormat(RemoveHTML(email))>
    	<cfset title = HTMLEditFormat(RemoveHTML(title))>
        <cfset startdate = HTMLEditFormat(RemoveHTML(startdate))>
        <cfset enddate = HTMLEditFormat(RemoveHTML(enddate))>
    	<cfset website = HTMLEditFormat(RemoveHTML(website))>
    	<cfset body = HTMLEditFormat(RemoveHTML(body))>
    	
    	<cfquery datasource="#dsn#" name="save">
    	insert into calendar_new (title, startDate, endDate, website, body, active, person, email)
    	values (#title#, '#DateFormat(startdate, "m/d/yyyy")#', '#DateFormat(enddate, "m/d/yyyy")#', '#website#', '#body#', #getSettings.activeComments#, '#person#','#email#')
    	</cfquery>
        
    	
    	<cfif getSettings.notifyComments and Len(getSettings.notifyEmail)>
    		<!--- notification email --->
    		<cfmail to="#getSettings.notifyEmail#" from="#getSettings.notifyEmail#" subject="New event from #person#" type="HTML">
    		<font face="Arial, sans-serif" size="3">
    		<font size="4"><b>New Event</b></font><br>
    		status: <b><cfif getSettings.activeComments>live<cfelse>pending approval</cfif></b><br>
    		<br>
    		<a href="http://#cgi.SERVER_NAME#/admin/comments_edit.cfm">Click here to <cfif getSettings.activeComments>view<cfelse>approve</cfif> or delete this comment</a><br>
    		<br>
    		name: #person#<br>
    		email: <a href="mailto:#email#">#email#</a><br>
            title: #title#<br>
            Start Date: #startdate#<br>
            End Date: #enddate#<br>
    		website: <cfif Len(website)><a href="<cfif Left(website, 4) neq "http">http://</cfif>#website#">#website#</a></cfif><br>
    		comments: #body#<br>
    		</font>
    		</cfmail>
    	</cfif>
    	 
    </cfif>
    
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>The Best of Cabo San Lucas Mexico - HotOnCabo.com</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <meta http-equiv="imagetoolbar" content="no">
    <style type="text/css">
    body {
    	margin: 0;
    	background-color: #f1eede;
    	background-image: url(/images/paper-tile.jpg);
    	background-position: top center;
    	background-repeat: repeat-y;
    }
    td, input, select, textarea, div {
    	font-family: Georgia, "Times New Roman", Times, serif;
    	font-size: 12px;
    	color: #49321f;
    }
    a {
    	color: #bb4700;
    	text-decoration: none;
    }
    a:hover {
    	color: #e59821;
    	text-decoration: none;
    }
    .title {
    	font-size: 18px;
    }
    .post {
    	font-family: Impact, Charcoal, sans-serif;
    	font-size: 18px;
    	color: #49321f;
    	text-decoration: none;
    	text-transform: uppercase;
    }
    .small {
    	font-family: Arial, Helvetica, sans-serif;
    	font-size: 11px;
    	color: #9d816c;
    	text-decoration: none;
    }
    .field {
    	border: 1px solid #49321f;
    	background-color: #ffffff;
    	width: 200px;
    }
    </style>
    <script language="JavaScript" type="text/javascript">
    <!--
    if(document.images) {
    	// preload
    	image1 = new Image();
    	image1.src = "/images/btn-save-comment-over.gif";
    	image2 = new Image();
    	image2.src = "/images/btn-cancel-over.gif";
    }
    function checkForm(obj) {
    	if(obj.person.value == "") {
    		alert("Please enter your name.");
    		obj.person.focus();
    		return false;
    	}
    	if(obj.title.value == "") {
    		alert("Please enter event name.");
    		obj.title.focus();
    		return false;
    	}
    	if(obj.startdate.value == "") {
    		alert("Please enter event start date.");
    		obj.startdate.focus();
    		return false;
    	}
    	if(obj.enddate.value == "") {
    		alert("Please enter event end date.");
    		obj.enddate.focus();
    		return false;
    	}
    	if(obj.body.value == "") {
    		alert("Please enter event description.");
    		obj.body.focus();
    		return false;
    	}
    	return true;
    }
    //-->
    </script>
    </head>
    
    <body onLoad="document.commentForm.person.focus();">
    <table width="100%" height="100%" cellpadding="0" cellspacing="0" border="0">
    <tr>
    	<td align="center">
    		<img src="/images/spacer.gif" width="250" height="10" border="0"><br>
    		
    			<img src="/images/text-add-comment.gif" width="181" height="26" border="0"><br>
    			<img src="/images/spacer.gif" width="1" height="5" border="0"><br>
    			<img src="/images/spacer.gif" width="1" height="10" border="0"><br>
    			<table cellpadding="4" cellspacing="0" border="0">
    			<cfoutput>
    			<form name="eventForm" action="#cgi.SCRIPT_NAME#" method="post" onSubmit="return checkForm(this);">
    
    			</cfoutput>
    			<tr>
    				<td>
    					Name: *<br>
    					<input type="text" name="person" size="20" maxlength="50" class="field"><br>
    				</td>
    			</tr>
    			<tr>
    				<td>Email:<br>
    					<input name="email" type="text" class="field" size="20" maxlength="50">
    				  <br>
    				</td>
    			</tr>
    			<tr>
    				<td>Title/Event:*<br>
    					<input name="title" type="text" class="field"  size="20" maxlength="50">
    				  <br>
    				</td>
    			</tr>
                <tr>
    				<td>
    					Start Date:*(m/d/yy)<br>
    					<input name="startdate" type="text" class="field" size="20" maxlength="20">
    				  <br>
    				</td>
    			</tr>
                            <tr>
    				<td>
    					End Date:*(m/d/yy)<br>
    					<input type="enddate" name="enddate" size="20" maxlength="20" class="field">
    					<br>
    				</td>
    			</tr>
    			<tr>
    				<td valign="bottom">
    					Website:<br>
    					<input type="text" name="website" size="20" maxlength="50" class="field"><br>
    				</td>
    			</tr>
    			<tr>
    				<td>
    					Comments: *<br>
    					<textarea name="body" cols="25" rows="7" class="field"></textarea>
    <br>
    				</td>
    			</tr>
    			<tr>
    				<td colspan="3" align="center">
    					<img src="/images/spacer.gif" width="1" height="10" border="0"><br>
    					<input type="image" src="/images/btn-save-comment-off.gif" width="101" height="20" border="0" onMouseOver="this.src='/images/btn-save-comment-over.gif';" onMouseOut="this.src='/images/btn-save-comment-off.gif';"><img src="/images/spacer.gif" width="30" height="20" border="0"><a href="javascript:self.close();"><img src="/images/btn-cancel-off.gif" width="41" height="20" border="0" onMouseOver="this.src='/images/btn-cancel-over.gif';" onMouseOut="this.src='/images/btn-cancel-off.gif';"></a><br>
    				</td>
    			</tr>
    			</form>
    			</table>
    	
    		<img src="/images/spacer.gif" width="1" height="10" border="0"><br>
    	</td>
    </tr>
    </table>
    <script type="text/javascript">
    var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
    document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
    </script>
    <script type="text/javascript">
    try {
    var pageTracker = _gat._getTracker("UA-3008253-5");
    pageTracker._trackPageview();
    } catch(err) {}</script>
    </body>
    </html>

    This is the error message I am getting:

    Error Diagnostic Information

    ODBC Error Code = 07001 (Wrong number of parameters)

    [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1.

    Hint: The cause of this error is usually that your query contains a reference to a field which does not exist. You should verify that the fields included in your query exist and that you have specified their names correctly.

    The error occurred while processing an element with a general identifier of (CFQUERY), occupying document position (20:2) to (20:41).

    Date/Time: 08/17/09 20:29:05
    Browser: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2
    Remote Address: 70.156.236.82
    HTTP Referrer: http://www.hotoncabo.com/event_add.cfm
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2008
    Posts
    39
    Rep Power
    11
    in ur insert statement, ue <cfqueryparam and for dates if u are using currentdates, try using createodbcdate(now()) which can minimise ur error

    Comments on this post

    • kiteless agrees
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2009
    Posts
    2
    Rep Power
    0
    That worked!!! thanks a million for your help
  6. #4
  7. No Profile Picture
    Moderator

    Join Date
    Jun 2002
    Location
    Raleigh, NC
    Posts
    5,307
    Rep Power
    972
    For future reference, please read the stickies on asking questions. Specifically, don't post a bunch of unrelated code, because all that does is make people not read it. Everyone is busy, so if you are asking for help, it's up to you to make your question as easy to answer as possible. 150 lines of code is almost a death sentence in terms of actually getting an answer, so more power to dodo for sticking with you.

IMN logo majestic logo threadwatch logo seochat tools logo