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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T17:39:37+00:00 2026-05-15T17:39:37+00:00

I am trying to set up a MySQL connection in a main script, and

  • 0

I am trying to set up a MySQL connection in a main script, and then call various functions depending on what I want to do. I am having trouble passing the connection information to the function.

I have a class “queries” which contains various functions, all which return an array. This is what the code looks like in my main script (calling function normal)

$mysqli = new mysqli($db_host, $db_user, $db_pass, $db_name) or die (mysql_error());
$stats = $queries->normal($mysqli);

And then inside of the queries resource, I have this code:

class queries {
    function normal($mysqli) {
        $query = "SELECT number, first, last FROM roster";
        $roster = $mysqli->query($query);

Then I proceed to do what I need. I cannot get this to work though. I get the error

Call to a member function normal() on a non-object

on the line that I call the function in my main file.

This is similar to these questions, but I can’t quite figure it out.
Passing database connection by reference in PHP
Ensuring MySQL connection works in PHP function

Thank you

  • 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-15T17:39:38+00:00Added an answer on May 15, 2026 at 5:39 pm

    “Call to a member function normal() on a non-object” means that you are trying to call normal() on a variable that is not an object. Probably you meant to do this:

    $queries = new queries();
    $stats = $queries->normal($mysqli);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to set up connection pooling to mysql databe with tomcat. My
I am trying to set up a release script to a MySQL database. I
I am trying to set the mysql connection in web config file. Here is
I am trying to set up a connection to my SQL server inside of
I am trying to set sql_mode in MySQL but it throws an error. Command:
I am trying to set the charset when letting Matlab connect to remote mysql
I am trying to use this MySQL query: SET @a:=0; UPDATE tbl SET sortId=@a:=@a+1
Trying to set it so if a certain condition is met then one of
I've been trying to obtain the Driver class for JDBC connection to MySQL. The
I'm trying to set up WordPress. I have Apache and MySQL running, and the

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.