|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
|||
|
|||
|
"Element XXX is undefined in.." error.
I am a new user to this group and a new user to ColdFusion as well, so please forgive my naivety here.
I am trying to pull fields from my database and have links to each record with the code as follows: <CFQUERY NAME="patients" DATASOURCE="febsetrack"> SELECT IECCenter, PTID, PTInitials, PtOnWeb, F1H01, F1H02, F1H03, F1H04, F1H05, F1H06, F1H07, F1H08 FROM FormReceiptTracking WHERE PatID=#URL.PTID# </CFQUERY> <CFOUTPUT> .... <tr> <th scope="row">#PTID#</th> <td>#PtOnWeb#</td> <td>#F1H01#</td> <td>#F1H02#</td> <td>#F1H03#</td> <td>#F1H04#</td> <td>#F1H05#</td> <td>#F1H06#</td> <td>#F1H07#</td> <td>#F1H08#</td> </tr> </table> </CFOUTPUT> When I try to test the page to see if it works, I get the following error every time: Element PTID is undefined in URL. <br>The error occurred on line 5. (Line 5 being "WHERE PatID=#URL.PTID#) Is there something not defined in my application.cfm file? Something that I have typed wrong (probably the case) or just plain beginner idiocy. I would appreciate any help that you could give me. Sincerely, DPVA94 |
|
#2
|
|||
|
|||
|
You're not correctly passing in the URL variable, or else you are looking at the page and the URL variable is not defined. So make sure you are passing the URL value correctly, something like this:
http://mysite.com/mypage.cfm?ptid=10 You can also set up a default value for url.ptid to use if/when one is not specified in the url before you try to run the query: <cfparam name="url.ptid" default="1" /> Hope that helps.
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian. How to Post a Question in the Forums |
|
#3
|
|||
|
|||
|
Ok, I tried what you said....
These are the error messages that I get now...so it must be something that I have coded wrong somewhere in my beginner's innocence.
Error Executing Database Query. [Macromedia][SequeLink JDBC Driver][ODBC Socket][Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression 'PatID='. <br>The error occurred on line 8. OR.... Error Executing Database Query. [Macromedia][SequeLink JDBC Driver][ODBC Socket][Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1. <br>The error occurred on line 8. OR... Element PTID is undefined in URL. <br>The error occurred on line 5. Below is the code that I have for the cfquery, etc. Where the errors occurred. I put the <cfparam> line that you gave me in at the very beginning and after the query itself. <!---Define URL.PTID variable---> <!---I also put this line after the last cfquery tag to try that as well---> <CFPARAM NAME="URL.PTID" DEFAULT="1" /> <!---Get a patient from the database---> <CFQUERY NAME="patients" DATASOURCE="febsenewtrack"> SELECT IECCenter, PTID, PTInitials, PtOnWeb, F1H01, F1H02, F1H03, F1H04, F1H05, F1H06, F1H07, F1H08 FROM FormReceiptTracking WHERE PatID=#URL.PTID# </CFQUERY> I appreciate your help. Sincerely, DPVA94 PS - Where are some really good places to go for beginners like me to get a strong foundation in CF basics? |
|
#4
|
|||
|
|||
|
What kind of data type is the PTID field in the database? Is it a number, a character, a date...?
I'd highly recommend Ben Forta's books, they're how virtually every CF developer learned CF. |
|
#5
|
|||
|
|||
|
PTID is a text id, for example a patient would be named something like "2P010".
|
|
#6
|
|||
|
|||
|
Then you'll need single quotes around it in the SQL, like this:
... WHERE PatID='#URL.PTID#' Once you have this working, you may want to look into using cfqueryparam, which creates a bind variable in the SQL statement. The appraoch you are using above has security issues (SQL injection attacks). But one thing at a time. ![]() |
|
#7
|
|||
|
|||
|
No kidding, pepper me with too much stuff at the same time, and my brain might explode.
I will try that today and see what happens. Nice thing is, I am getting my new laptop today and will have time to practice this stuff at home. ColdFusion is the first programming language that I have actually wanted to learn indepth, and I appreciate your help in starting the foundations of that. I am sure more questions will be coming your way. Back to the grind! ![]() |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > "Element XXX is undefined in.." error. |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|