Skip to main content
Inspiring
March 24, 2007
Answered

cf/dw error

  • March 24, 2007
  • 20 replies
  • 2397 views
This is really holding me up now. i posted the other for some help with some simple insert cf code. i still dont have this working and ive tried everythng there is to try. ive got a feeling that there is something wrong either with dw or cf server.

currently i am getting the following error message from within dw:

"while executing insepctserverbehanior in InsertRecord.htm, the following javascript error(s) occured:

At line 576 of file "C:\program file\macromedia\dreamweaver 8\configuration\servermodels\coldfusion\dwscriptsserverimpl.js
typeerror: sqlVarRef has no properties"

i get this error message when i open up my new insert_new_admin_user.cfm page

so i have tried:

1, re writing the code several times
2, creating new table in the access db
3, repaired/install of dw
4, upgraded from cf server 6 to cf server 7
5, searched for help online

the strange thing is that other insert code works fine on pages that i created ages ago. its only the new ones that dont work. ive even tried coping the code from old pages and just changing the bits i need to but still doesnt work.

please see the other post for further details.
http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?forumid=1&catid=2&threadid=1252879&enterthread=y

really need some help here. i wanted to have my site finised this weekend ...... but looks like it aint gunna happen :-(

edit>>> ive just tried something else: tried doing away with the sql altogether but i still get the same error which is

Error Executing Database Query.
Syntax error in INSERT INTO statement.

The error occurred in F:\data\webdesigns\wwwroot\CFIDE\Allied\newadminuser.cfm: line 1

1 : <cfinsert datasource="allieddatabase" tablename="admin_users_table1">

the cf code im using for this one was:

<cfinsert datasource="allieddatabase" tablename="admin_users_table1">

zac
This topic has been closed for replies.
Correct answer SafariTECH
change the code in the INSERT from "level" to "[level]"

and then re-try submitting the form and see what happens.

20 replies

Inspiring
March 29, 2007
Error Executing Database Query.
Syntax error in INSERT INTO statement.

Ok so now we need to look at your insert query. Do you see in the debug
output. If you have full debugging turned on, it should be showing the
processed SQL statement. Can you post that.
zac1234Author
Inspiring
March 29, 2007
no the error was

Error Executing Database Query.
Syntax error in INSERT INTO statement.


this is the result from the cf dump - interesting?

FIELDNAMES FULL_USER_NAME,USER_DEPT,USER_ID,USER_PW,USER_PW_CONFIRM,USER_LEVEL,SUBMIT
FULL_USER_NAME [empty string]
SUBMIT Submit
USER_DEPT OPS
USER_ID [empty string]
USER_LEVEL yes
USER_PW [empty string]
USER_PW_CONFIRM [empty string]

Inspiring
March 28, 2007
What was the error? Undefined value?

If so, was an option selected on the form. IIRC if no option is
selected then the variable does not exist on the form structure passed
to the action page.

Adding this to the top of your action page can help see what is being
passed and what is not.

<cfdump var="#form#">

zac1234Author
Inspiring
March 28, 2007
The error occurred in F:\data\webdesigns\wwwroot\CFIDE\Allied\newadminaction.cfm: line 9

7 : '#form.user_pw#',
8 : '#form.user_pw_confirm#',
9 : '#form.level#' )
10 : </cfquery>
11 :
Inspiring
March 28, 2007
Your error message is telling the entire story. You did not change
'new_admin_use' to 'form' on line four.

4 : '#new_admin_user.full_user_name#',
SHOULD BE
4 : '#form.full_user_name#',

zac1234 wrote:
> yep thought you might say that, i meant to edit my post to say i had already
> tried that.
>
> this is the error message i get from that:
>
> Element FULL_USER_NAME is undefined in NEW_ADMIN_USER.
>
> The error occurred in
> F:\data\webdesigns\wwwroot\CFIDE\Allied\newadminaction.cfm: line 4
>
> 2 : INSERT INTO admin_users_table (full_user_name, user_dept, user_id,
> user_pw, user_pw_confirm, level)
> 3 : VALUES (
> 4 : '#new_admin_user.full_user_name#',
> 5 : '#form.user_dept#',
> 6 : '#form.user_id#',
>
>
zac1234Author
Inspiring
March 28, 2007
yes i noticed that as soon as i posted so i corrected it and still got a simular error see last post.

have you got anymore ideas? i'm neally ready to top myself :-((
zac1234Author
Inspiring
March 27, 2007
yep thought you might say that, i meant to edit my post to say i had already tried that.

this is the error message i get from that:

Error Executing Database Query.
Syntax error in INSERT INTO statement.

The error occurred in F:\data\webdesigns\wwwroot\CFIDE\Allied\newadminaction.cfm: line 9

7 : '#form.user_pw#',
8 : '#form.user_pw_confirm#',
9 : '#form.level#' )
10 : </cfquery>
11 :


EDIT <<< >>>>just discovered that "level" is a reserved word in access, so changed it to user_level but still didnt work
Inspiring
March 27, 2007
so what s right with or without the # ?

Yup, I can see your problem now.

With the hash/pound/# is required, but you are naming your variables wrong.

On your form page, the form is named "new_admin_user" and this can be
used for javascript purposes at that time. But once the form is
submitted to that action page, the data structure is named "form".

Your insert will need to look something like this:
<cfquery name="add_new_admin" datasource="allieddatabase">
INSERT INTO admin_users_table
(full_user_name, user_dept, user_id, user_pw, user_pw_confirm, level)
VALUES
('#form.full_user_name#',
'#form.user_dept#',
'#form.user_id#',
'#form.user_pw#',
'#form.user_pw_confirm#',
'#form.level#' )
</cfquery>

Of course an even better practice would be to wrap each of those
variables in a proper <cfqueryParam ...> tag. Something like:
VALUES
(<cfqueryParam value="#form.full_user_name#"
cfSqlType="cf_sql_varchar">, ... )

zac1234Author
Inspiring
March 27, 2007
ok, thanks for getting back.

this is what the code looks like if i do it myself - i know what you are going to say first of all that the VALUES need to have # blabla# around them. if i wrap the VALUES in # then all i get is
"new_admin_user.full_user_name is undefined in form"

if i take the # away the message i get is:

rror Executing Database Query.
Syntax error in INSERT INTO statement.

The error occurred in F:\data\webdesigns\wwwroot\CFIDE\Allied\newadminaction.cfm: line 1

1 : <cfquery name="add_new_admin" datasource="allieddatabase">
2 : INSERT INTO admin_users_table (full_user_name, user_dept, user_id, user_pw, user_pw_confirm, level)
3 : VALUES ('new_admin_user.full_user_name', 'new_admin_user.user_dept', 'new_admin_user.user_id', 'new_admin_user.user_pw', 'new_admin_user.user_pw_confirm', 'new_admin_user.level' )

so what s right with or without the # ?

here is my html code:

<form method="POST" name="new_admin_user" action="newadminaction.cfm">
<label for="full_user_name">Name</label>
<input type="text" name="full_user_name" id="full_user_name">
<label for="user_dept">Department</label>
<select name="user_dept" id="app_select">
<option selected>OPS</option>
<option>Sales</option>
<option>Accounts</option>
<option>P&W</option>
<option>General management</option>
</select>
<label for="user_id">user name</label>
<input type="text" name="user_id" id="use_id">
<label for="user_pw">Password</label>
<input type="text" name="user_pw" id="user_pw">
<label for="user_pw_comfirm">Confirm Password</label>
<input type="text" name="user_pw_confirm" id="user_pw_confirm">
<label for="level">Level</label>
<select name="level" id="app_select">
<option>yes</option>
<option>no</option>
</select>
<br>
<input name="Submit" type="submit" id="submit_button" value="Submit">
</form>

its just supposed to be a simple insert into the db of the form contents. when i click on submit it should take me to the newadminuseraction.cfm page but instead it i get the error messages.

is this the info you needed?
Inspiring
March 26, 2007
currently i am getting the following error message from within dw:

"while executing insepctserverbehanior in InsertRecord.htm, the
following javascript error(s) occured:


Two thoughts:

This is a DW error and may not be impacting your actual functionality.
DW itself uses quite a bit of JavaScript in it's wizards and such. Is
your code not working when run on the server? If it does work you can
ignore the DW error as annoying as it is.

There is a caching bug in DW itself. If you have the "Maintain
synchronization information" option selected on the "Remote Info"
section of the Site Definition it can cause problems. It prevents the
file date-time stamp from changing when a file is uploaded so that CF
does not realize a new version of the file is available and that it
needs to recompile it. You can either turn off this option, or download
and install the DW patch the fixes this bug.

zac1234Author
Inspiring
March 26, 2007
thanks for the info Ian. i did as you said and it has fixed the dw issue but my code still doesnt work :-( i have tried testing my code locally and i have uploaded to my web server but still no joy.

could you run your eyes over the code for my incase i'm missing something please?

<cfset CurrentPage=GetFileFromPath(GetTemplatePath())>
<cfif IsDefined("FORM.MM_InsertRecord") AND FORM.MM_InsertRecord EQ "new_admin_user">
<cfquery datasource="allieddatabase">
INSERT INTO admin_users_table1 (full_user_name, user_dept, user_id, user_pw, user_pw_confirm, level)
VALUES (
<cfif IsDefined("FORM.full_user_name") AND #FORM.full_user_name# NEQ "">
'#FORM.full_user_name#'
<cfelse>
NULL
</cfif>
,
<cfif IsDefined("FORM.user_dept") AND #FORM.user_dept# NEQ "">
'#FORM.user_dept#'
<cfelse>
NULL
</cfif>
,
<cfif IsDefined("FORM.user_id") AND #FORM.user_id# NEQ "">
'#FORM.user_id#'
<cfelse>
NULL
</cfif>
,
<cfif IsDefined("FORM.user_pw") AND #FORM.user_pw# NEQ "">
'#FORM.user_pw#'
<cfelse>
NULL
</cfif>
,
<cfif IsDefined("FORM.user_pw_confirm") AND #FORM.user_pw_confirm# NEQ "">
'#FORM.user_pw_confirm#'
<cfelse>
NULL
</cfif>
,
<cfif IsDefined("FORM.level") AND #FORM.level# NEQ "">
'#FORM.level#'
<cfelse>
NULL
</cfif>
)
</cfquery>
<cflocation url="adminusers.cfm">
</cfif>

this code was generated by using the dw "insert record" wizard. i first creted my own code but that didnt wok either so i thought i'd try this.

any more thoughts? thanks for the help so far.

zac
Inspiring
March 25, 2007
if you have changed the code so there is no SQL and still get this error, it sounds like CF is caching the page and not serving up the new page ... either that or it is not actually transferring the page to the server.

check in the Admin section and make sure it is not caching pages and or clear the cache
zac1234Author
Inspiring
March 25, 2007
thanks for getting back.

i tried what you said. the caching pages option is not selected in the cf admin area. i tried selecting it the restarting then deselecting and restarting just to see if that helped it. i also tried re doing the code with and without the sql but still not working.

this is the current cf code on the page:

<cfset CurrentPage=GetFileFromPath(GetTemplatePath())>
<cfif IsDefined("FORM.MM_InsertRecord") AND FORM.MM_InsertRecord EQ "new_admin_user">
<cfquery datasource="allieddatabase">
INSERT INTO admin_users_table1 (full_user_name, user_dept, user_id, user_pw, user_pw_confirm, level)
VALUES (
<cfif IsDefined("FORM.full_user_name") AND #FORM.full_user_name# NEQ "">
'#FORM.full_user_name#'
<cfelse>
NULL
</cfif>
,
<cfif IsDefined("FORM.user_dept") AND #FORM.user_dept# NEQ "">
'#FORM.user_dept#'
<cfelse>
NULL
</cfif>
,
<cfif IsDefined("FORM.user_id") AND #FORM.user_id# NEQ "">
'#FORM.user_id#'
<cfelse>
NULL
</cfif>
,
<cfif IsDefined("FORM.user_pw") AND #FORM.user_pw# NEQ "">
'#FORM.user_pw#'
<cfelse>
NULL
</cfif>
,
<cfif IsDefined("FORM.user_pw_confirm") AND #FORM.user_pw_confirm# NEQ "">
'#FORM.user_pw_confirm#'
<cfelse>
NULL
</cfif>
,
<cfif IsDefined("FORM.level") AND #FORM.level# NEQ "">
'#FORM.level#'
<cfelse>
NULL
</cfif>
)
</cfquery>
<cflocation url="adminusers.cfm">
</cfif>

and this is the error message i get back:

Error Executing Database Query.
Syntax error in INSERT INTO statement.

The error occurred in F:\data\webdesigns\wwwroot\CFIDE\Allied\newadminuser.cfm: line 40

38 : <cfelse>
39 : NULL
40 : </cfif>
41 : )
42 : </cfquery>


what do you make of this? any help would be so much appreciated

zac

P.S. its worth mentioning that my other insert pages do work. its only new pages that dont - does that help at all?