Skip to main content
April 24, 2006
Answered

URL problem

hey, i'm in need of some help with my coldfusion code. this is the problem, i currently have a set up with increasing links depending on how much information is inputted into the database. this is the code im using to accomplish this feature.

<cfset max = 5>
<cfparam name="url.start" default="1">

<cfoutput query="info" startrow="#url.start#" maxrows="#max#">
#info.name# | #info.message# <br>
</cfoutput>

<cfset pages = ceiling(info.recordcount/max)>
<cfif pages gt 1>
<cfloop from="1" to="#pages#" index="i">
<cfoutput>
<a href="home.cfm?number=#url.n#?start=#val((i*max)-(max-1))#">#i#</a>
</cfoutput>
</cfloop>
</cfif>

Here is my error message:

Error Executing Database Query
and it points to this part of my code:

where number=#url.n#

I noticed that the increasing link number code works fine on the other pages i use it at but the code is a little different on the other pages i use it at because i have the link part set up like this:

<a href="home.cfm?start=#val((i*max)-(max-1))#">#i#</a>

and at the page im using it where i get the error i need it to be like this:

<a href="home.cfm?number=#url.n#?start=#val((i*max)-(max-1))#">#i#</a>

this is where i think the problem is at because i also noticed on the error page that the information is being read like this:

select name
from people
where number=12?start=1


and number in the database should be only 12 but for some reason coldfusion keeps reading the rest of the url and i think thats where the problem is....

could anyone help me? i would greatly appreciate any type of help...
thanks!!
    This topic is closed to new replies. Start a new post to keep the conversation going.
    boughtonpCorrect answer
    Inspiring
    April 25, 2006
    You only use question mark (?) to initiate the query string.
    To delimit it, the default character is ampersand (&).
    Look at the URL of this page for an example.

    Also, it is wise to use the CFQUERYPARAM tag when using user-controlled variables in queries, to help prevent unwanted database access.

    1 reply

    boughtonpCorrect answer
    Inspiring
    April 25, 2006
    You only use question mark (?) to initiate the query string.
    To delimit it, the default character is ampersand (&).
    Look at the URL of this page for an example.

    Also, it is wise to use the CFQUERYPARAM tag when using user-controlled variables in queries, to help prevent unwanted database access.
    Translate