Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Passing a simple id via url using a hyperlink problem

Participant ,
Mar 26, 2009 Mar 26, 2009
I can't believe I can't figure this one out, I am passing an id via the url variables using a hyper link. It comes back with an error in my linked page saying there is an error in the way I used a function. I don't get it, it's a function I use all the time. Here is my queries that are passing and receiving the id.

indexpage:
<cfquery name="useRec" datasource="#APPLICATION.dataSource#">
SELECT user.Fname AS ViewField1, user.email AS ViewField6, user.Lname AS ViewField3, user.userName AS ViewField4, user.password AS ViewField5, lastLogin, hits, user.ID AS ID
FROM user
</cfquery>

<cfoutput query="useRec">
<a href="page2.cfm?ID=#ID#" class="nav">View user Record</a>
</cfoutput>

PAGE 2

<cfparam name="ID" type="integer" default="#url.ID#">
<cfquery name="useRec" datasource="#APPLICATION.dataSource#">
SELECT user.Fname AS ViewField1, user.email AS ViewField6, user.Mname AS ViewField2, user.Lname AS ViewField3, user.userName AS ViewField4, user.password AS ViewField5, user.admin AS ViewField6 user.lastLogin AS lastLogin, user.hits AS hits, user.ID
FROM user
<cfif isDefined("URL.ID")>
WHERE ID = <cfqueryparam value="#URL.ID#" cfsqltype="cf_sql_integer">
</cfif>
</cfquery>

this is my error:
Error Executing Database Query. [Macromedia][SequeLink JDBC Driver][ODBC Socket][Microsoft][ODBC Microsoft Access Driver] The SELECT statement includes a reserved word or an argument name that is misspelled or missing, or the punctuation is incorrect.
The error occurred on line 11.

It is throwing an error on my if statement. I have tried a number of different options and still the same error.

Can anyone see what I might have missed?

Thank you.
502
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Mar 26, 2009 Mar 26, 2009
your table name - USER - is very likely a reserved word in your database.

try using it in square brackets: [user]

btw, since you are selecting from only one table, you do not need to
prefix every column name with table name...

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/
Translate
LEGEND ,
Mar 26, 2009 Mar 26, 2009
your table name - USER - is very likely a reserved word in your database.

try using it in square brackets: [user]

btw, since you are selecting from only one table, you do not need to
prefix every column name with table name...

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 26, 2009 Mar 26, 2009
Azadi answered your question. My general suggestion is to start paying closer attention to your error messages. For some reason, you misinterpreted the one you got big time.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Mar 26, 2009 Mar 26, 2009
LATEST
Yes he did. I also found that I missed a comma in my query. It is all fixed now. I had to walk away from it for a couple of hrs to find it.

Thank you for the help.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources