SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    ********* obeah makeda's Avatar
    Join Date
    Jun 2001
    Location
    rollin' on dubs
    Posts
    492
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    OOP - counting records

    I am trying to create an object in php which has methods that connect to the database, run a query and count the records:

    PHP Code:
    class DbConnect {

    var 
    $db;
    var 
    $recordCount;
    var 
    $oReturnQuery;
    var 
    $sQuery;

      function 
    DbConnect() {
        
    $this->db mysql_connect($hostname,$user,$pass);
        
    mysql_select_db($database,$this->db);
      }
      
      function 
    runQuery($sQuery) {
       
        
    $oReturnQuery mysql_query($sQuery,$this->db);
        
    $this->recordCount mysql_result($oReturnQuery0);    
        return 
    $oReturnQuery;
      }   

    This line keeps blowing up on me:

    $this->recordCount = mysql_result($sReturnQuery, 0);

    And I get this error:
    Warning: Supplied argument is not a valid MySQL result resource

    Any ideas why? When I use this:

    mysql_result($oReturnQuery, 0);

    outside of the object, it works fine.
    Last edited by makeda; Apr 8, 2002 at 10:36.

  2. #2
    SitePoint Guru
    Join Date
    Mar 2002
    Posts
    608
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What happens when you try that line without:
    , 0

    ?

  3. #3
    ********* obeah makeda's Avatar
    Join Date
    Jun 2001
    Location
    rollin' on dubs
    Posts
    492
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    When i try it without ',0', I get this error message:

    Warning: Wrong parameter count for mysql_result()


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •