473,659 Members | 3,631 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ADODB recordcount returns 0 although is should be 1

1 New Member
Hey everyone,

I have the problem that one and the same SQL query returns two different results.

1. When executed in PHPMyAdmin, the query returns 1 record set.

2. When executed in the script, recordcount returns 0.

This is the query in plain:

select users.uid, users.name, users.mail, users.status, users_roles.uid , users_roles.rid , role.rid from users LEFT JOIN users_roles ON (users.uid = users_roles.uid ) LEFT JOIN role ON (users_roles.ri d = role.rid) WHERE users.name = 'username' AND MD5('password') = users.pass AND role.rid = 3

And this is the relavant code segment:

Expand|Select|Wrap|Line Numbers
  1. if (!$adodb_drupal) $adodb_drupal = connect_adodb(DB_NAME_DRUPAL);
  2.  
  3.     //Check the input for illegal chars
  4.     $current_username     = check_input($_POST['username'],"username");
  5.     $current_password     = check_input($_POST['password'],"password");
  6.  
  7.     // check the input with concrete rules
  8.     $input_check     = "";
  9.     $input_check  .= check_username($current_username);
  10.     $input_check  .= check_password($current_password);
  11.  
  12.     // Input check is only filled if either the username or the password is worng! This is done in the function check_username/check_password.
  13.     // Username/password are wrong if they contain certain characters or are too long or empty! 
  14.     if ($input_check != "") 
  15.     {                    
  16.         // output/log
  17.         update_log(trim($input_check,"\,"));                                        
  18.     }
  19.  
  20.     // Check user in Drupal DB
  21.  
  22.     $current_password = utf8_encode($current_password);
  23.  
  24.     $query = "select 
  25.                 users.uid,
  26.                 users.name,
  27.                 users.mail,
  28.                 users.status,
  29.                 users_roles.uid,
  30.                 users_roles.rid,
  31.                 role.rid
  32.                 from users
  33.                 LEFT JOIN users_roles ON (users.uid = users_roles.uid)
  34.                 LEFT JOIN role ON (users_roles.rid = role.rid)
  35.                 WHERE users.name = '" . $current_username . "'  
  36.                 AND MD5('".$current_password."') = users.pass
  37.                 AND role.rid = 3";
  38.  
  39.     $result = $adodb_drupal->Execute($query);
  40.  
  41.     // IF the result is filled, the user exists and we check if the user is active or not
  42.     if (($result != FALSE) AND ($result->RecordCount() > 0))
  43.     {
  44.         // User found, checking status is active    
  45.         if ($result->fields['status'] == 1) 
  46.         {
  47.             update_log("SUCCESS - user/pwd match active user. Username: " . $current_username);
  48.             $_SESSION["uid"] = $result->fields['uid'];
  49.  
  50.             // If the user exists and is active we have "success"
  51.             $_SESSION["authorization"] = "success";
  52.             $_SESSION["action"] = "home";
  53.             $action = "home";
  54.             $validate ="1";
  55.             $_POST['validate'] = "1";
  56.  
  57.             $User_ID = $result->fields['uid'];
  58.         } 
  59.         else 
  60.         {
  61.             update_log("FAILED - user/pwd match user not active. Username: " . $current_username);
  62.  
  63.             // If the user exists, but is not active, we have "notactive"
  64.             $_SESSION['authorization'] = "notactive";
  65.         }                                        
  66.     } 
  67.     else 
  68.     {
  69.         update_log("FAILED - no user/pwd match. Username: " . $current_username);
  70.  
  71.         // If the user is not in the database we have "unknown"
  72.         $_SESSION['authorization'] = "unknown";        
  73.     }
  74.     $adodb_drupal->close();
  75.  
Does anyone have an idea? As I said, the query returns a result when executed in the database, but not in the script.

Cheers,

Fred
Jul 27 '11 #1
0 1205

Sign in to post your reply or Sign up for a free account.

Similar topics

1
2202
by: skeeterbug | last post by:
hi all, i'm new to using php, adodb and pgsql. i have a need to enter data into a database. however, i can't find a web example or tutorial that explains the nuts and bolts of how this is done. in general terms, does it go like this...
4
4968
by: Navin Kulshreshtha | last post by:
Hi folks, I'm opening a recordset with a SQL statement and then trying to use the .RecordCount property to count the number of rows in the recordset. For some reason, it is always returning -1. Here's the code (I have left out the details for the connection string): ------------------- strSQL = "SELECT * from orders" strConnect = Set osRecordSet = Server.CreateObject("ADODB.Recordset") osRecordset.Open strSQL, strConnect
7
41842
by: Serge Myrand | last post by:
Hi, I have an ADODB.RecordSet that RecordCount alway return -1 and this RecordSet is plenty of record! R.RecordSet = -1 R.eof = False R.BOF = False Is the cursor is lost somewhere?
0
1899
by: Dot Netizen | last post by:
I am having trouble passing an ADODB.Recordset from a VB6 application to a VB.Net class library using COM Interop. I am running this on XP SP2 with the .Net Framework 1.1 and MDAC 2.8 SP1. I've compiled the VB.Net DLL and registered it so it can be used in the VB6 app using "regasm /tlb:VBNETClass.tlb VBNETClass.dll". From the VB6 app, I added a reference to the VB.Net DLL. (Both classes also reference the ADO 2.8 Library.) I then built...
12
2967
by: scott | last post by:
In LISTING 2, I have a SPROC that returns a recordset and a recordcount in SQL QA. I can access the Recordset with no problem. How can I grab the Recordcount with ASP code at the same time I'm getting the Recordset? In QA, the RecordCount displays below the Recordset. The below USAGE code will display my SPROC results. USAGE: EXEC SELECT_WITH_PAGING 'CustomerID, ShipName', 'OrderID', 'Northwind.dbo.Orders', 3, 10, 1, '', 'OrderDate'...
4
15130
by: jl | last post by:
Hello, I am trying to determine if a recordset is empty or not, and if it is empty print out a message saying no records found. I thought I could use rs.RecordCount but it always seems to return -1 no matter if there are records in the rs or not. Does anyone have any ideas as to why this doesn't work and how to get it to work. Thanks in advance. The code is below. Joe Const adOpenStatic = 3
2
2074
by: nick_faye | last post by:
why does my recordcount returns the # of actual records + 1? btw, i am using ms access. i don't know what happened but at first, my table seems ok. the recordcount returns the correct # of records. but as i manipulate the table, (add, delete, etc) i get errors and when i checked my recordcount, it returns 1 more than the actual # of records. what did i do? how can i avoid this to happen again? please help! nick_faye
2
3866
by: Rick Brown | last post by:
I get a "subscript out of range" error when I run this code. "Rcount = rsSupplierCode.RecordCount" Returns 49 BUT "numReturned = UBound(varRecords, 2) + 1" Returns only 3 I'm I wrong to believe both should return 49? Dim dbs As DATABASE Dim qdfSupplierCode As QueryDef
1
3244
pureenhanoi
by: pureenhanoi | last post by:
I'm using VB6 and MSAcces DataBase my project have one Conection called: GPcnxn, a Recordset called: GPrs. If i connect to database by DataEnvironment, so, after this command Set Gprs=Gpcnx.excute("..."), i can get: Gprs.RecordCount, Gprs.AbsolutePossition If i connect to database by DNS, so, after that command, both GPrs.RecordCount and GPrs.AbsolutePossition are return -1 i'll tried using : gprs.open sqlQuery,Gpcnxn,1,3. So,...
8
19116
code green
by: code green | last post by:
I have been working with a script I have inherited that uses the ADODB class. I want to run a query that checks a record is unique across the primary key and date field in a MsSql DB before inserting, so I am using this function ADODB::Execute() to run this query SELECT 1 FROM table WHERE pk = 'code' AND eff_date = 'newdate'. Which hopefully returns an empty recordset. But when I call ADODB::RecordCount() to confirm the count is zero the...
0
8337
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8628
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7359
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6181
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5650
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4175
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4335
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2754
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1739
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.