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.

New Topic/Question
Reply




MultiQuote




|