3 Replies - 3878 Views - Last Post: 21 June 2012 - 12:10 PM Rate Topic: -----

#1 rikkp  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 17
  • Joined: 26-March 12

database query error

Posted 21 June 2012 - 10:28 AM

OK so the user selects a state from page one and this sends them to the action page (StateDB.cfm) with the URL var called state.
This page displays the data for the state selected on the left side and a form on the right(action set to submit back to the same page)
If the user selects a state using the form dropdown, the page reloads and displays the state data fist selected on the left and the newly selected state data on the right.
It works fine on my local machine but when I uploaded it to several different ColdFusion servers, It works fine the first time the page loads and displays the state data but when the second state is selected and submitted I get the dreaded error executing database query to few parameters. Expecting 1
Page One
<a href="StateDB.cfm?state=Massachusetts" target="_blank">to action page </a>



Here is the code for the action page
<!--- first page load will have the url var called state set  and will display the data for that state on the left and will set a var called state1 to that same url var --->
<cfif IsDefined("url.State")>
<cfquery name="compareSoil" datasource="backpacklab">
select * from soilTest
where state = '#url.state#'
</cfquery>

<cfset state1 = '#State#'>
<!--- If the page loaded and the user submitted the form back to the page a second time --->
<cfelse>
<cfquery name="compareSoil" datasource="backpacklab">
select * from soilTest
where state = '#State1#'
</cfquery>

</cfif>

<cfoutput query="compareSoil">
<table>
<tr class="text">
<td width="293">#city#</td>
    <td width="131">#username#</td>
    <td width="131">#phLevel#</td>
  </tr>
  </cfoutput> 
</table>
<!--- the form on this same page was submitted with 3 VARs -StateTwo- and 2 hidden set to- #state# and #state1# --->
<cfif IsDefined("FORM.StateTwo") AND #FORM.StateTwo# NEQ "">
    <cfset state2 = #form.StateTwo#>
    <cfquery name="compare" datasource="backpacklab">
select * from soilTest
where state = '#State2#'
</cfquery>
 <cfoutput query="compare">
<tr>
<td>#city#</td>
    <td>#username#</td>
    <td>#phLevel#</td>
    
  </tr>
  </cfoutput>
<cfelse>
<!--- show the form to select second state VAR -->
<cfoutput>
<form name="compare" id="compare" action="StateDB.cfm" method="post">
    <input type="text" name="StateTwo">
    <input type="hidden" name="state1"  value="<cfoutput>#state1#</cfoutput>" />
    <input type="hidden" name="state"  value="<cfoutput>#state#</cfoutput>" />
<input name="submit" type="submit" value="Compare" />
</form>


This post has been edited by Atli: 21 June 2012 - 10:44 AM
Reason for edit:: Fixed the [code] ... [/code] tags.


Is This A Good Question/Topic? 0
  • +

Replies To: database query error

#2 Craig328  Icon User is offline

  • I make this look good
  • member icon

Reputation: 1947
  • View blog
  • Posts: 3,488
  • Joined: 13-January 08

Re: database query error

Posted 21 June 2012 - 11:32 AM

Hi rikkp. Your error would depend upon which query is erroring for you. Is it the one starting on line 3 or the one starting line 11? According to your description of the problem, it sounds like it should be the second one but let us know.
Was This Post Helpful? 0
  • +
  • -

#3 rikkp  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 17
  • Joined: 26-March 12

Re: database query error

Posted 21 June 2012 - 12:05 PM

There are 3 querys
The third query on line 30 is the one throwing the error.
Was This Post Helpful? 0
  • +
  • -

#4 Craig328  Icon User is offline

  • I make this look good
  • member icon

Reputation: 1947
  • View blog
  • Posts: 3,488
  • Joined: 13-January 08

Re: database query error

Posted 21 June 2012 - 12:10 PM

Ah. Okay.

<cfif IsDefined("FORM.StateTwo") AND #FORM.StateTwo# NEQ "">
   <cfset state2 = #form.StateTwo#>
   <cfquery name="compare" datasource="backpacklab">
      select * from soilTest
      where state = '#State2#'
   </cfquery>



"FORM.StateTwo" isn't the same as "State2". You're checking for one thing but applying another. Could that be it?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1