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

  • Home
  • SEARCH
  • 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 8113215
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T02:45:28+00:00 2026-06-06T02:45:28+00:00

This is the weirdest bug! It is probably something silly, but I have no

  • 0

This is the weirdest bug! It is probably something silly, but I have no idea how to fix it. If anyone could help, I would be most grateful! I have three files, one is called items.php, another is called tableFunctions.php, and the third is called mysql.php. I use two global objects called ‘mysql’ and ‘tableFunctions’. They are stored in the files ‘mysql.php’, and
‘tableFunctions.php’, respectively. In each file, I create an instance of its object, assigning it to the global variable $_mysql, or $_table. like this:

In the file mysql.php:

global $_mysql;
$_mysql = new mysql();

In the file tableFunctions.php:

global $_table;
$_table = new tableFunctions();

Here’s how it is supposed to work:

The items.php file includes the tableFunctions.php file…
Which in turn, needs the mysql.php file, so it includes it too.

In the items.php file, I call the method getTable(), which is contained in the object tableFunctions.(and in the variable $_table.) Like this:

$t = $_table->getTable('items');

The getTable function calls the method, arrayFromResult(), which is contained within in the object mysql.(and in the variable $_mysql.) Like this:

$result  = $_mysql->arrayFromResult($r);

That’s where I get the error. PHP says that the variable ‘$_mysql’ is undefined, but I defined it in the ‘mysql.php’ file.(see above) I also included mysql.php with the following code:

include_once 'mysql.php';

I have no idea what is wrong! If anyone can help that would be much appreciated.
The source files can be downloaded with the following link: https://www.dropbox.com/sh/bjj2gyjsybym89r/YLxqyNvQdn

  • 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-06T02:45:29+00:00Added an answer on June 6, 2026 at 2:45 am

    That’s a common mistake, in the place of definition you need only the line:

    $_mysql = new mysql();
    

    and when you want to use it inside a function, only there you have to declare it as a global variable (otherwise it is considered like any other function variable):

    global $_mysql;
    

    so, for example, if we’ll take your method:

    function getTable($tableName) {         
            $r = mysql_query("SELECT * FROM $tableName");
                err($r, 'mysql returned null when getting table!');
    
            $result  = $_mysql->arrayFromResult($r);
            return $result;
        }
    

    it should be changed to:

    function getTable($tableName) {
            global $_mysql;
            $r = mysql_query("SELECT * FROM $tableName");
                err($r, 'mysql returned null when getting table!');
    
            $result  = $_mysql->arrayFromResult($r);
            return $result;
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Okay, this is by far the weirdest bug I have ever encountered. It's pretty
this is the weirdest error I've ever got on Rails. Any idea what this
Hey this is the weirdest problem i've ever encoutered, I have 2 projects that's
I know this one is the weirdest of all weird questions I have asked
I just found a solution to one of the weirdest bug i have ever
Ok this is the weirdest thing I have seen in a while... I am
This is the weirdest behaviour I have encountered in default set of controls/helpers in
I have the weirdest bug, when writting my LogHelper class. I am using org.osgi.service.log.LogService
This is probably the dumbest question ever here on stack Overflow. But I am
This has got to be one of the most frustratingly stupid bugs I have

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.