Fatal error: Call to a member function num_rows() on a non-object in /home/a8164291/p

Discussion in 'PHP' started by subhasis, Aug 7, 2009.

  1. #1
    HI
    I AM A STUDENT I JUST CAME UP WITH THIS ERROR MESSAGE ..
    CAN ANY ONE please HELP
    :::
    THE EXACT ERROR CODE WAS
    ::
    Fatal error: Call to a member function num_rows() on a non-object in /home/a8164291/public_html/application/models/applicationmodel.php on line 89

    ///////////////////////////////////////////////////////////////////////////////////////
    <?php

    /**
    * User Model
    *
    *
    */
    class Applicationmodel extends Model
    {
    //Constructor
    function Applicationmodel()
    {
    parent::Model();
    }
    function getApplications($onlyBasic = false)
    {
    if ($onlyBasic == true) $appQuery = $this->db->query('SELECT * FROM applications WHERE user_id=0');
    else $appQuery = $this->db->query('SELECT * FROM applications');
    if ($appQuery->num_rows() > 0)
    {
    $applications = array();
    foreach ($appQuery->result_array() as $appRow)
    {
    $applications[$appRow['application_id']] = $appRow;
    }
    return $applications;
    }
    else return false;
    }
    function getUserApplications()
    {
    $this->db->select('application_ids');
    $this->db->where('user_id', $this->session->userdata('user_id'));
    $this->db->limit(1, 0);
    $userAppQuery = $this->db->get('users_applications');
    if ($userAppQuery->num_rows() > 0)
    {
    $userAppRow = $userAppQuery->result_array();
    $appQuery = $this->db->query('SELECT * FROM applications WHERE application_id IN (' . $userAppRow[0]['application_ids'] . ')');
    if ($appQuery->num_rows() > 0)
    {
    $applications = array();
    foreach ($appQuery->result_array() as $appRow)
    {
    $applications[$appRow['application_id']] = $appRow;
    }
    return $applications;
    }
    else return false;
    }
    else return false;
    }
    function isApplication($appName)
    {
    $this->db->where('application_name', $appName);
    $this->db->limit(1, 0);
    $appQuery = $this->db->get('applications');
    if ($appQuery->num_rows() > 0)
    {
    $appRow = $appQuery->result_array();
    return $appRow[0]['application_id'];
    }
    else return false;
    }
    function isUserCanAccessTheApplication($applicationId)
    {
    $this->db->select('application_ids');
    $this->db->where('user_id', $this->session->userdata('user_id'));
    $this->db->limit(1, 0);
    $userAppQuery = $this->db->get('users_applications');
    if ($userAppQuery->num_rows() > 0)
    {
    $userAppRow = $userAppQuery->result_array();
    $userAppArray = explode(',', $userAppRow[0]['application_ids']);
    if (array_search($applicationId, $userAppArray) === false) return false;
    else return true;
    }
    else return false;
    }
    function getLanguages()
    {
    $this->db->select('lang_code, lang_name');
    $this->db->from('languages');
    $langQuery = $this->db->get();
    $languages = array();
    if ($langQuery->num_rows() > 0)
    {
    foreach ($langQuery->result_array() as $langRow)
    {
    $languages[] = $langRow;
    }
    }
    return $languages;
    }
    }

    ?>
     
    subhasis, Aug 7, 2009 IP
  2. premiumscripts

    premiumscripts Peon

    Messages:
    1,062
    Likes Received:
    48
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Something is wrong with $appQuery.

    Add this:

    
    echo "<pre>";
    print_r($appQuery);
    echo" </pre>
    
    PHP:
    before this line:

    
    if ($appQuery->num_rows() > 0)
    
    PHP:
    And report back with the results.

    You may also want to add this at the top of the file:

    
    ini_set('display_errors', 1);
    error_reporting(E_ALL);
    
    PHP:
    And lastly, you may want to show us the source code for the DB class as well.
     
    premiumscripts, Aug 7, 2009 IP
  3. subhasis

    subhasis Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    got this error message after i inserted this code :
    echo "<pre>";
    print_r($appQuery);
    echo" </pre>
    ////////////////////////////////////////////
    error code ::parse error: syntax error, unexpected '[', expecting ']' in /home/a8164291/public_html/application/models/applicationmodel.php on line 33
     
    subhasis, Aug 7, 2009 IP
  4. premiumscripts

    premiumscripts Peon

    Messages:
    1,062
    Likes Received:
    48
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Oops, that is supposed to be
    echo "</pre>";
    PHP:
    ... sorry :)
     
    premiumscripts, Aug 7, 2009 IP
  5. subhasis

    subhasis Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    sorry actually the error is ::
    Parse error: syntax error, unexpected ']', expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/a8164291/public_html/application/models/applicationmodel.php on line 96
    ..............................................
     
    subhasis, Aug 7, 2009 IP
  6. Codex-m

    Codex-m Peon

    Messages:
    36
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Try replacing
    
    return $languages;
    
    Code (markup):
    with:

    
    return $languages[];
    
    Code (markup):
    Just try..
     
    Codex-m, Aug 7, 2009 IP
  7. IshanFdo

    IshanFdo Greenhorn

    Messages:
    68
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #7
    thanks For The Help And I got The Same Error Also Now The Error Is

    Parse error: syntax error, unexpected ']', expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/a4080554/public_html/application/models/applicationmodel.php on line 98

    Here's The Code!
     
    Last edited: Oct 25, 2011
    IshanFdo, Oct 25, 2011 IP
  8. IshanFdo

    IshanFdo Greenhorn

    Messages:
    68
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #8
    Line 98 Is
     
    Last edited: Oct 25, 2011
    IshanFdo, Oct 25, 2011 IP
  9. IshanFdo

    IshanFdo Greenhorn

    Messages:
    68
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #9
    Check For the New Error of Mine Plz
     
    IshanFdo, Oct 26, 2011 IP