Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

getting error passing variable to query

Status
Not open for further replies.

dunskii

Programmer
Sep 14, 2001
107
AU
Hi all,

I am getting an error when i pass a variable from a link to a querry on the next page.

Heres the code:
<cfquery name=&quot;getAll_rent&quot; datasource=&quot;dunskii&quot; dbtype=&quot;ODBC&quot;>
SELECT * FROM property_rent WHERE rent_id EQ '$id'
</cfquery>

and heres the error:

[Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression 'rent_id EQ '$id''.



The error occurred while processing an element with a general identifier of (CFQUERY), occupying document position (48:5) to (48:67).


cheers,
d
 
by any chance are you from a PHP background ??

Coldfusion uses the #variable# syntax so your query should look like this:

SELECT *
FROM property_rent
WHERE rent_id = '#id#'

also when dealing with queries coldfusion uses the normal = sign for equal to and so on !

tony


 
yeah i have been doing a bit of php work lately, ok i changed that and now i get this error

Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression.



The error occurred while processing an element with a general identifier of (CFQUERY), occupying document position (49:5) to (49:67).

 
right then if rent_id is a numeric field then you don't need the ' around the variable name. so your where statement will look like this:

WHERE rent_id = #id#

I am going the other way at the moment CF to PHP...and tips ?

Tony
 
can you recommend a good book that covers PHP one that covers advanced features as well as the more simple things

i have seen a recommendation for a book bt welling and thomson called php and mysql web development. heard of it ? and good ?

glad your problem is sorted !
 
no havent heard of it, i've been using the mastering php and mysql, published by sybex
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top