Skip to main content
Participating Frequently
November 9, 2006
Question

Varible Undefined

  • November 9, 2006
  • 19 replies
  • 1522 views
My company has a db of events. Uses submit them and admins are e-mail. This page is for "approval" after the event is approved it will be show on the main page. I keep gettign Varible ZERO undefined error and im nto sure why. Ill attach the form and the action page. If you need more information of more of an explination email em at TFort@PreventPollution.org
This topic has been closed for replies.

19 replies

Participating Frequently
November 10, 2006
Read my first post. That's where I meant you used <cfparam>, not in the query.

Post all the occurences of Approved on both the form and the action page.
TomFortAuthor
Participating Frequently
November 10, 2006
Well i know i did not use CFparam.
here the exact SQL :

<cfset WorkshopKey = FORM.WorkshopKey>
<cfquery name="EditEvents" datasource="testEvents">
UPDATE
1Events
SET
EventName = '#EventName#',
StartDate = '#StartDate#',
EndDate = '#EndDate#',
EventDescription = '#EventDescription#',
Contact = '#Contact#',
MailTo = '#mailto#',
ContactPhone = '#ContactPhone#',
ContactOrganization = '#ContactOrganization#',
Website = '#Website#',
OtherInfoDescription = '#OtherInfoDescription#',
OtherInfoLink = '#OtherInfoLink#',
Approved = '#Approved#',
Zero = '#Zero#'
WHERE
WorkshopKey = <cfoutput>#WorkshopKey#</cfoutput>
</cfquery>
<cfinclude template="detailtest.cfm">

I have no idea were the , is coming from .
Participating Frequently
November 9, 2006
Nope, you didn't do anything wrong. I bet you have the following at the top of your action page:
<cfparam name="FORM.Approved" default=",0">

Note the extra comma. Take that comma out.

If that isn't it, post the _exact_ SQL update query. From the error, somehow an extra comma is getting in there between the single quote and #Approved#, or the value of Approved actually includes a comma.
TomFortAuthor
Participating Frequently
November 9, 2006
Thanks guys that all helped so much..

But now there a new issue.
When i click approve or zero it then send the varibles wrong..

Error Executing Database Query.
[Macromedia][SequeLink JDBC Driver][ODBC Socket][Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression.

The error occurred in C:\CFusionMX\wwwroot\0-waste\admin\Events\Approved\ACT_edit.cfm: line 23

21 : Approved = '#Approved#'
22 : WHERE
23 : WorkshopKey = <cfoutput>#WorkshopKey#</cfoutput>
24 : </cfquery>
25 : <cfinclude template="detailtest.cfm">

then show all the blah=blah stuff fromthe update command then it shows..
Zero = '0', Approved = ' ,0'
But only if there clicked..

The form looks like this:

<tr valign="baseline">
<td nowrap align="right">Approve</td>
<td> <input type="checkbox" name="Approved" value="True" <cfif Recordset1.Approved is True>checked="Yes"</cfif>/></td>
</tr>

<tr valign="baseline">
<td nowrap align="right">Zero Waste</td>
<td> <input type="checkbox" name="Zero" value="True" <cfif Recordset1.Zero is True>checked="Yes"</cfif>/></td>
</tr>

Maybe I did somthing wrong there..

tclaremont
Inspiring
November 9, 2006
Or, you could do this on the processing page:

<CFIF Not IsDefined #Form.Zero#>
<CFSET Zero = whatever>
</CFIF>

Note that I did not say that I LIKED that idea...
Participating Frequently
November 9, 2006
Zero is a checkbox. Checkboxes only get submitted with the form if they're checked.

Add the following code to the top of your action page:

<cfparam name="FORM.Zero" default="False">

Also, I'm not quite sure I understand the input field for Zero. You have it as follows:
<input type="checkbox" name="Zero" <cfif Recordset1.Zero is True>Value="True" <cfelseif Recordset1.Zero is False>Value="False" </cfif>/>

So if it's False, they can never change it to True. What you want is the following:
<input type="checkbox" name="Zero" value="True" <cfif Recordset1.Zero is True>checked="Yes"</cfif>/>
November 9, 2006
Zero is not getting set. Do you try to set it elsewhere in a code block that is not being executed?
TomFortAuthor
Participating Frequently
November 9, 2006
Variable ZERO is undefined.

The error occurred in E:\web\public_html\zero\zerowastenetwork-net\admin\Events\Approved\ACT_workshopkey.cfm: line 18

16 : OtherInfoLink = '#OtherInfoLink#',
17 : Approved = '#Approved#',
18 : Zero = '#Zero#'
19 : WHERE
20 : WorkshopKey = <cfoutput>#WorkshopKey#</cfoutput>
Inspiring
November 9, 2006
looks like your Recordset1 query does not return column 'Zero' in its results. Add this line after that query (after the closing </cfquery> tag) and see if there is a field called 'Zero' in the results:

<cfdump var="#Recordset1#">

It will be a lot easier to find the source of the problem if yuo provided:
a) the scope referenced in the CF error message (i.e. where CF can't find the ZERO variable)
b) code line number referenced in the CF error message