Closed (fixed)
Project:
Drupal core
Version:
6.1
Component:
database system
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
31 Mar 2009 at 13:27 UTC
Updated:
29 Jun 2010 at 10:10 UTC
Dear All,
Pls help. I am a newbie..I am getting an error like this "warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /srv/www/htdocs/Sathish/includes/common.inc(1645) : eval()'d code on line 45."
I am trying to select the data from the DB . At that time ,I am getting the above error. Thanks for any help/
Comments
Comment #1
dipen chaudhary commentedYou'll need to use drupal's abstraction API
Instead of mysql_num_rows -> In drupal 6 u'll need to adapt your queries - http://drupal.org/node/114774#db-num-rows
Look at the all the database api here - http://api.drupal.org/api/group/database/6
Instead of mysql_query u'd use db_query and hence forth. Also if you can post your code here.
Comment #2
dipen chaudhary commentedComment #3
Sathishkumar-2 commentedYes. U r absolutely right dipen chaudhary!!! Thanks . Also I need to insert values into the external database from the story node . Should i do this using db_query itself or is there any other command for insertion?
Comment #4
yasir farooqui commentedAs db_num_rows is not available in drupal 6 and also calling mysql_num_rows in drupal 6 some times gives the mentioned warning, so I just wrote a custom function for this and wanted to share here. Now rather than building your sql count query each time you need to count number of results, its better if you have some generic function, here is what I have written:
Note that this could have been accomplished by using regular expression to replace with the "Count(*)" string, but I used this because I am not too good in regular expressions :)
You will call this function as following:
Comment #5
yasir farooqui commentedIn fact I found the regular expression for this :) I found this in one of the drupal's include file: Here is the updated function:
Comment #6
avpadernohttp://drupal.org/update/modules/5/6#db-num-rows reports what to do, instead of using the function that has been removed.
I am marking this support request as fixed because it has been already replied from dipen chaudhary.