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 7904317
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T10:00:00+00:00 2026-06-03T10:00:00+00:00

I have a script that is supposed to read from the database and return

  • 0

I have a script that is supposed to read from the database and return an array which is used by another function to display a table. However the function is throwing an error.

Fatal error: Call to a member function fetch_array() on a non-object in C:\xampp\htdocs\nu\userClass.php on line 205

I don’t know what could be the error because I have already created an object for the MySQLi class. Here is my code

function getUser($user_id)
        {
            require("config.php");
            //TODO Clean variables
            $dbc = new mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
            /* check connection */
            if (mysqli_connect_errno()) 
            {
            printf("Connect failed: %s\n", mysqli_connect_error());
            exit();
            }
            $query2 = "SELECT family.Position, food.Meal "."FROM family, food "."WHERE family.Position = food.Position";    
            $result = $dbc->query($query2);
            $row = $result->fetch_array();
            /* close connection */
            $dbc->close();
            return $row;
        }
  • 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-06-03T10:00:02+00:00Added an answer on June 3, 2026 at 10:00 am

    This error message seems to say that you have an error in your SQL query.

    Try replacing the call to $dbc->query() by the following lines :

    $result = $dbc->query($query2);
    if ($result === false) {
        echo 'MySQL error: ' . $dbc->error;
    }
    

    This will show you a more detailed error message.

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

Sidebar

Related Questions

I have a powershell script that needs to read from a config file with
I have a script that is supposed to sit there, happily running in a
I have a PHP script that's supposed to take in a URL and search
I have a Ruby 1.8.6 script that is supposed to take a filename that
I have a Perl script, that's supposed to match this string: Sometimes, he says
I have a script that will fetch data from server and compose a DIV
I have a script that does images resizing on load: $( document ).ready( function()
Hey everyone, I have written a script that downloads a zip file from a
I have read that 302 HTTP errors are not supposed to appear frequently even
I have a Perl script that does a fork/exec to start another tool in

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.