EasyCFM.COM ColdFusion Forums / Coding Help! / Login question

   Reply to Discussion | New Discussion << previous || next >> 
Posted By Discussion Topic: Login question -- page: 1 2

book mark this topic Printer-friendly Version  send this discussion to a friend  new posts last

ed
06-25-2003 @ 10:46 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Senior Member
Posts: 173
Joined: Apr 2003

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
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Junior Member
Posts: 56
Joined: Jun 2003

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
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Administrator
Posts: 4262
Joined: Oct 2002

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 Smile  



CJ
@ #coldfusion/DALNet
http://charlie.griefer.com

ed
06-25-2003 @ 12:21 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Senior Member
Posts: 173
Joined: Apr 2003

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
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Administrator
Posts: 4262
Joined: Oct 2002

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
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Junior Member
Posts: 56
Joined: Jun 2003

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
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Junior Member
Posts: 56
Joined: Jun 2003

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
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Senior Member
Posts: 173
Joined: Apr 2003

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
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Junior Member
Posts: 56
Joined: Jun 2003

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
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Administrator
Posts: 4262
Joined: Oct 2002

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

PAGE: 1 2
Sponsored By...
Mobile App Development (IOS, Android, Cordova, Phonegap, Objective-C, Java) - Austin, Texas Mobile Apps - Touch512, LLC.