Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7037075
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:30:00+00:00 2026-05-28T01:30:00+00:00

When i get this error: Call to a member function query() on a non-object

  • 0

When i get this error:
Call to a member function query() on a non-object

Now when im going to the line it specifies then i see this:

// Count the rows of a table
$query = $this->c->query("SELECT COUNT(*) as `rows` FROM ".$query) or die($this->c->error);
$row = $query->fetch_assoc();

$result = $row['rows'];
return $result;

Now after some trying i found out that it gives me the right result when i do die($result); before returning it, there it gives the result i need.

When i check what line calls the function then i see this:

if($this->num_rows("accounts WHERE id='".$_SESSION['user_id']."'") == 0)

My class i build like this:

I make a class Db where there is a function num_rows, then i make a class User that extends the Db class, in the constructor of the User class i initialize the Db class by doing parent::__construct(); i’m 100% sure the class gets initialized since i can do real-escape strings but not execute any queries O.o anybody that can help me with this?

Some extra information:

when i print_r my connection it gives this:

mysqli Object ( [affected_rows] => 1 [client_info] => mysqlnd 5.0.8-dev - 20102224 -     $Revision: 310735 $ [client_version] => 50008 [connect_errno] => 0 [connect_error] => [errno] => 0 [error] => [field_count] => 1 [host_info] => localhost via TCP/IP [info] => [insert_id] => 0 [server_info] => 5.5.16 [server_version] => 50516 [sqlstate] => 00000 [protocol_version] => 10 [thread_id] => 715 [warning_count] => 0 ) mysqli Object ( [affected_rows] => 1 [client_info] => mysqlnd 5.0.8-dev - 20102224 - $Revision: 310735 $ [client_version] => 50008 [connect_errno] => 0 [connect_error] => [errno] => 0 [error] => [field_count] => 1 [host_info] => localhost via TCP/IP [info] => [insert_id] => 0 [server_info] => 5.5.16 [server_version] => 50516 [sqlstate] => 00000 [protocol_version] => 10 [thread_id] => 715 [warning_count] => 0 )

Question i got in my head is why it got 2 mysqli objects in it??

Db class = http://pastebin.com/yvDij0kG
User class = http://pastebin.com/ndwa2YRr

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T01:30:01+00:00Added an answer on May 28, 2026 at 1:30 am

    Ok found my own bug :p was because i was overriding the constructor and because of that i couldn’t initiate my object outside it’s own constructor.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When I execute a MySQLi query with my custom function I get this error...
whenever I try to call my ejb from a client, I get this error
I get this error: System.Reflection.TargetException: Object does not match target type. when trying to
Possible Duplicate: Error : get property of non-object I am new to codeigniter model,
Can anyone tell me I get the error: Fatal error: Call to a member
When I execute this code I get an error saying PHP Fatal error: Call
I can't figure out why I get this error : /usr/local/include/boost/asio/impl/read.hpp: In member function
I get this error when I try to use a model: fatal error: Call
I get this error when I try to use a model: fatal error: Call
I get this error: Can't locate Foo.pm in @INC Is there an easier way

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.