| ed | -- 06-25-2003 @ 10:46 AM |
|
I got this error when I log in succesfully, the code is below and a link to the screengrab of my db is attached, what`s going on here?? The table names? TIA: Element COUNTRY_CODE is undefined in QVERIFY. The Error Occurred in C:\CFusionMX\wwwroot\login_process.cfm: line 17 15 : self.location=entryindexpage_; 16 : </script> 17 : <cfset entry_page = "entryindexpage_" & #qVerify.country_code# & ".cfm"> 18 : <script> 19 : load_index('#entry_page#'); <!--- Get all records from the database that match this users credentials ---> <cfquery name="qVerify" datasource="excelbd"> SELECT user_name, user_pass FROM tblAdmins WHERE user_name = '#user_name#' AND user_pass = '#user_pass#' </cfquery> <cfif qVerify.RecordCount> <!--- This user has logged in correctly, change the value of the session.allowin value ---> <cfset session.allowin = "True"> <!--- Now welcome user and redirect to "members_only.cfm" ---> <script> alert("Welcome"); self.location=entryindexpage_; </script> <cfset entry_page = "entryindexpage_" & #qVerify.country_code# & ".cfm"> <script> load_index('#entry_page#'); </script> <cfset entry_page = "entryindexpage_" & #qVerify.country_code# & ".cfm"> < cfelse> <!--- this user did not log in correctly, alert and redirect to the login page ---> <script> alert("Wrong entry"); self.location="Javascript:history.go(-1)"; </script> </cfif> ![]()
|
|
| roninthecode | -- 06-25-2003 @ 11:16 AM |
|
Your query does not specify the fieldname country_code so the element qVerify.country_code does not exist in line 17 try this: <cfquery name="qVerify" datasource="excelbd"> SELECT user_name, user_pass, country_code FROM tblAdmins WHERE user_name = '#user_name#' AND user_pass = '#user_pass#' </cfquery> but be aware that <cfset entry_page = "entryindexpage_" & #qVerify.country_code# & ".cfm"> results in i.e.: entryindexpage_1.cfm entryindexpage_2.cfm, etc. if the result needs to be i.e.: entryindexpage_panama.cfm you need to make a join in your query hope this helps A 'stupid' question does not exist: only stupid awnsers..
|
|
| CJ | -- 06-25-2003 @ 11:31 AM |
|
try: <cfquery name="qVerify" datasource="excelbd"> SELECT tblAdmins.user_name, tblAdmins.user_pass, COUNTRIES.country_code FROM tblAdmins INNER JOIN COUNTRIES ON tblAdmins.country_code = COUNTRIES.Id WHERE tblAdmins.user_name = '#user_name#' AND tblAdmins.user_pass = '#user_pass#' </cfquery> oughtta do it. If i had more time, i'd chide you for not using <cfqueryparam>...but I'm incredibly late at the moment. see http://tutorial138.easycfm.com/ for now and I'll be back to chide you later CJ @ #coldfusion/DALNet http://charlie.griefer.com
|
|
| ed | -- 06-25-2003 @ 12:21 PM |
|
Thanks a lot CJ and roninthecode!! Following the advice of roninthecode and the code of CJ if I execute the CJ solution i nthe reply given me I get the following error: Error Executing Database Query. [MERANT][SequeLink JDBC Driver][ODBC Socket][Microsoft][Microsoft Access Controller ODBC] The type doesn`t coincide in the expression. The Error Occurred in C:\CFusionMX\wwwroot\login_process.cfm: line 19 17 : 18 : 19 : <cfif qVerify.RecordCount> 20 : <!--- This user has logged in correctly, change the value of the session.allowin value ---> 21 : <cfset session.allowin = "True"> -------------------------------------------------------------------------------- SQL SELECT tblAdmins.user_name, tblAdmins.user_pass, COUNTRIES.country_code FROM tblAdmins INNER JOIN COUNTRIES ON tblAdmins.country_code = COUNTRIES.Id WHERE tblAdmins.user_name = 'guatemala' AND tblAdmins.user_pass = 'riveravon' DATASOURCE excelbd VENDORERRORCODE -3079 SQLSTATE HY000 I then added in the select COUNTRIES.Id to get the following code: <cfquery name="qVerify" datasource="excelbd"> SELECT tblAdmins.user_name, tblAdmins.user_pass, COUNTRIES.country_code COUNTRIES.Id FROM tblAdmins INNER JOIN COUNTRIES ON tblAdmins.country_code = COUNTRIES.Id WHERE tblAdmins.user_name = '#user_name#' AND tblAdmins.user_pass = '#user_pass#' </cfquery> however now I get the following error: Error Executing Database Query. [MERANT][SequeLink JDBC Driver][ODBC Socket][Microsoft][Controlador ODBC Microsoft Access] Syntax error(missing operator) in the consultation expression 'COUNTRIES.country_code COUNTRIES.Id'. The Error Occurred in C:\CFusionMX\wwwroot\login_process.cfm: line 19 17 : 18 : 19 : <cfif qVerify.RecordCount> 20 : <!--- This user has logged in correctly, change the value of the session.allowin value ---> 21 : <cfset session.allowin = "True"> -------------------------------------------------------------------------------- SQL SELECT tblAdmins.user_name, tblAdmins.user_pass, COUNTRIES.country_code COUNTRIES.Id FROM tblAdmins INNER JOIN COUNTRIES ON tblAdmins.country_code = COUNTRIES.Id WHERE tblAdmins.user_name = 'guatemala' AND tblAdmins.user_pass = 'riveravon' DATASOURCE excelbd VENDORERRORCODE -3100 SQLSTATE 42000 Any ideas where I`m going wrong? TIA
|
|
| CJ | -- 06-25-2003 @ 12:45 PM |
|
ya, you need a comma after COUNTRIES.country_code in your SELECT. (after COUNTRIES.country_code and before COUNTRIES.Id) CJ @ #coldfusion/DALNet http://charlie.griefer.com
|
|
| roninthecode | -- 06-25-2003 @ 12:45 PM |
|
try this SELECT user_name, user_pass, countries.country_code FROM tblAdmins, countries WHERE user_name = '#user_name#'AND user_pass = '#user_pass#'AND countries.ID=tbladmins.country_code </cfquery> hope it helps A 'stupid' question does not exist: only stupid awnsers..
|
|
| roninthecode | -- 06-25-2003 @ 12:52 PM |
|
after posting above i saw the missing comma aswell. so stick with CJ's advice and place the comma (he has a more thorough knowledge, then me anyway) goodluck A 'stupid' question does not exist: only stupid awnsers..
|
|
| ed | -- 06-25-2003 @ 1:03 PM |
|
Hi CJ and Roninthecode, We must be nearly there now!! I put the missing comma in(thanks)however I`m getting the following error-could it be a problem with my db fields? TIA: Error Executing Database Query. [MERANT][SequeLink JDBC Driver][ODBC Socket][Microsoft][Controlador ODBC Microsoft Access] The type of expression doesn`t coincide. The Error Occurred in C:\CFusionMX\wwwroot\login_process.cfm: line 15 13 : </cfquery> 14 : 15 : <cfif qVerify.RecordCount> 16 : <!--- This user has logged in correctly, change the value of the session.allowin value ---> 17 : <cfset session.allowin = "True"> ------------------------------------------------------- SQL SELECT tblAdmins.user_name, tblAdmins.user_pass, COUNTRIES.country_code, COUNTRIES.Id FROM tblAdmins INNER JOIN COUNTRIES ON tblAdmins.country_code = COUNTRIES.Id WHERE tblAdmins.user_name = 'guatemala' AND tblAdmins.user_pass = 'riveravon' DATASOURCE excelbd VENDORERRORCODE -3079 SQLSTATE HY000 The code being used is: <!--- Get all records from the database that match this users credentials ---> <cfquery name="qVerify" datasource="excelbd"> SELECT tblAdmins.user_name, tblAdmins.user_pass, COUNTRIES.country_code, COUNTRIES.Id FROM tblAdmins INNER JOIN COUNTRIES ON tblAdmins.country_code = COUNTRIES.Id WHERE tblAdmins.user_name = '#user_name#' AND tblAdmins.user_pass = '#user_pass#' </cfquery> <cfif qVerify.RecordCount> <!--- This user has logged in correctly, change the value of the session.allowin value ---> <cfset session.allowin = "True"> <!--- Now welcome user and redirect to "members_only.cfm" ---> <script> alert("Welcome"); self.location=entryindexpage_; </script> <cfset entry_page = "entryindexpage_" & #qVerify.country_code# & ".cfm"> <script> load_index('#entry_page#'); </script> <cfset entry_page = "entryindexpage_" & #qVerify.country_code# & ".cfm"> < cfelse> <!--- this user did not log in correctly, alert and redirect to the login page ---> <script> alert("Wrong entry"); self.location="Javascript:history.go(-1)"; </script> </cfif> This message was edited by ed on 6-25-03 @ 1:05 PM
|
|
| roninthecode | -- 06-25-2003 @ 1:47 PM |
|
make this: <cfif qVerify.RecordCount> this: <cfif qVerify.RecordCount EQ 1> A 'stupid' question does not exist: only stupid awnsers..
|
|
| CJ | -- 06-25-2003 @ 2:05 PM |
|
no, that's not the issue. That is just doing a boolean evaluation and is perfectly valid. Also, the error is a JDBC error, which is a database error. Altho CF is pointing at line 17, it's actually the SQL before line 17. I'm going to go ahead and guess that the datatypes of the joined columns aren't identical. Can you confirm that tblAdmins.country_code and COUNTRIES.Id are both the same datatype? I'm betting one's a Number and one's Text. CJ @ #coldfusion/DALNet http://charlie.griefer.com
|
|
| ed | -- 06-25-2003 @ 2:54 PM |
CJ, Here is the screen grab... This message was edited by ed on 6-25-03 @ 2:55 PM
|
|
| CJ | -- 06-25-2003 @ 3:05 PM |
|
which confirms what I suspected... the code i gave you joins COUNTRIES.Id (numeric) on tblAdmins.country_code (text). your country_code field in the tblAdmins should really be countryID (or something similar), as it doesn't relate to the country_code table in COUNTRIES. country_code in COUNTRIES is the full name of the country. country_code in tblAdmins is the Id value. are you following? CJ @ #coldfusion/DALNet http://charlie.griefer.com
|
|
| ed | -- 06-25-2003 @ 3:27 PM |
Thanks for the reply, yes I think I more or less get what you mean. Should the tblAdmins.user_id be replaced by (the newly renamed)tblAdmins.countryID included in the screen grab?TIA ![]() This message was edited by ed on 6-25-03 @ 3:28 PM
|
|
| CJ | -- 06-25-2003 @ 3:41 PM |
|
tblAdmins.user_id doesn't need to be changed. here's the changes I would make (based on your latest screen grab): 1) rename COUNTRIES.Id to COUNTRY.country_id 2) rename tblAdmins.countryID to tblAdmins.country_id 3) change the datatype of tblAdmins.countryID from text to Number (integer) that's it. everything else is fine. CJ @ #coldfusion/DALNet http://charlie.griefer.com
|
|
| ed | -- 06-25-2003 @ 4:36 PM |
|
Hi CJ, thanks a lot for the help, I`ve done the changes you asked for: (pls. see new screen grab) and I`ve also changed the code in the cfm to supposedly deal with those changes. However I am getting an error: Error Executing Database Query. [MERANT][SequeLink JDBC Driver][ODBC Socket][Microsoft][Controlador ODBC Microsoft Access] Pocos parĂ¡metros. Se esperaba 1. The Error Occurred in C:\CFusionMX\wwwroot\login_process.cfm: line 15 13 : </cfquery> 14 : 15 : <cfif qVerify.RecordCount> 16 : <!--- This user has logged in correctly, change the value of the session.allowin value ---> 17 : <cfset session.allowin = "True"> ------------------------------------------------------- SQL SELECT tblAdmins.user_name, tblAdmins.user_pass, COUNTRY.country_code, COUNTRY.country_id FROM tblAdmins INNER JOIN COUNTRY ON tblAdmins.countryId = country.country_Id WHERE tblAdmins.user_name = 'guatemala' AND tblAdmins.user_pass = 'riveravon' DATASOURCE excelbd VENDORERRORCODE -3010 SQLSTATE 07002 The code of the cfm is: <!--- Get all records from the database that match this users credentials ---> <cfquery name="qVerify" datasource="excelbd"> SELECT tblAdmins.user_name, tblAdmins.user_pass, COUNTRY.country_code, COUNTRY.country_id FROM tblAdmins INNER JOIN COUNTRY ON tblAdmins.countryId = country.country_Id WHERE tblAdmins.user_name = '#user_name#' AND tblAdmins.user_pass = '#user_pass#' </cfquery> <cfif qVerify.RecordCount> <!--- This user has logged in correctly, change the value of the session.allowin value ---> <cfset session.allowin = "True"> <!--- Now welcome user and redirect to "members_only.cfm" ---> <script> alert("Welcome"); self.location=entryindexpage_; </script> <cfset entry_page = "entryindexpage_" & #qVerify.country_code# & ".cfm"> <script> load_index('#entry_page#'); </script> <cfset entry_page = "entryindexpage_" & #qVerify.country_code# & ".cfm"> < cfelse> <!--- this user did not log in correctly, alert and redirect to the login page ---> <script> alert("Wrong entry"); self.location="Javascript:history.go(-1)"; </script> </cfif> ![]() This message was edited by ed on 6-25-03 @ 4:52 PM
|
|
| CJ | -- 06-25-2003 @ 4:48 PM |
|
well now you have to change your join. you're referencing columns that don't exist anymore. your current join: tblAdmins INNER JOIN COUNTRY ON tblAdmins.countryId = country.Id country.Id no longer exists. your query should now look like: <cfquery name="qVerify" datasource="excelbd"> SELECT tblAdmins.user_name, tblAdmins.user_pass, COUNTRY.country_code, COUNTRY.country_id FROM tblAdmins INNER JOIN COUNTRY ON tblAdmins.country_id = country.country_id WHERE tblAdmins.user_name = '#user_name#' AND tblAdmins.user_pass = '#user_pass#' </cfquery> you might want to think about picking yourself up a SQL Reference. Ben Forta's got one that I understand is pretty decent. CJ @ #coldfusion/DALNet http://charlie.griefer.com This message was edited by CJ on 6-25-03 @ 4:49 PM
|
|
| ed | -- 06-25-2003 @ 5:08 PM |
|
Hi CJ, yes you are right I will buy a sql book because I think I really need it-thanks for putting up with me today and being so helpful. The app worked(more or less) passing me through to the javascript alert saying welcome. However when I click on the alert button it takes me back(or leaves me on rather) the same login_process.cfm page. If I right click to view source I get: <script> alert("Welcome"); self.location=entryindexpage_; </script> <script> load_index('#entry_page#'); </script> Why is it not sending me to the right page? The actual links I have in the db --- COUNTRY.link --- should I change the db feild name to entry_page ? TIA for this which I hope will be my last question before I buy the sql book...!!
|
|
| apletfx | -- 06-25-2003 @ 11:02 PM |
|
Ed, You either need to surround the variable with cfoutput tags <script> load_index('<cfoutput>#entry_page#</cfoutput>'); </script> or use a cflocation instead. <cflocation url="#entry_page#"> try that. ============================= Never settle with words what you can Accomplish with a flame-thrower. - Bruce Feirstein =============================
|
|
| ed | -- 06-26-2003 @ 1:40 PM |
|
Hi Apletfx: Thanks Pixeljunkie!! Perfect!! I used <cflocation url="#entry_page#"> and it works great. My question is will this stop users who are logged in moving to other index pages? At the moment the users get sent to the same folder the index they get depends on the country. I have some users who need to be able to see all the sites, but the majority can only see the index page. would it be in my application.cfm that I set these porperties? Application.cfm: <!--- Create the application ---> <cfapplication name="MyApp" clientmanagement="Yes" sessionmanagement="Yes" sessiontimeout="#CreateTimeSpan(0,0,15,0)#" applicationtimeout="#CreateTimeSpan(0,2,0,0)#"> <!--- Now define that this user is logged out by default ---> <CFPARAM NAME="session.allowin" DEFAULT="false"> <!--- Now if the variable "session.allowin" does not equal true, send user to the login page ---> <!--- the other thing you must check for is if the page calling this application.cfm is the "login.cfm" page and the "Login_process.cfm" page since the Application.cfm is always called, if this is not checked the application will simply Loop over and over. To check that, you do the following call ---> <cfif session.allowin neq "true"> <cfif CGI.SCRIPT_NAME EQ "/login.cfm"> <cfelseif CGI.SCRIPT_NAME EQ "/login_process.cfm"> <cfelse> <!--- this user is not logged in, alert user and redirect to the login.cfm page ---> <script> alert("You must login to access this area!"); self.location="/login.cfm"; </script> </cfif> </cfif>
|
|
| EasyCFM.COM ColdFusion Forums : | http://www.easycfm.com/forums |
| Topic: | http://www.easycfm.com/forums/viewmessages.cfm?Forum=12&Topic=1086 |