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

The Archive Base Latest Questions

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

I have a sample code: class DBConnect { private $connect = null; private $query

  • 0

I have a sample code:

class DBConnect {
    private $connect = null;
    private $query = null;
    public $result = 0;
    public $data = null;
    public $_result;

    function connect() {
        $this->connect = mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_PASS) or die("Can't connect database");
        mysql_query("set names 'utf8'");
        mysql_select_db(MYSQL_NAME, $this->connect);
    }

    function close() {
        if($this->connect) {
            mysql_close($this->connect);    
        }
    }

    function query($sql) {
        $this->query = mysql_query($sql);
        if(!$this->query) {
            echo "Error: " . mysql_error();
            exit;
        }
    }

    function get_data($category_id) {
        $sql = 'SELECT id, name FROM category WHERE id='.$category_id;
        query($sql); // This is error
        $row = mysql_fetch_object($query);
        $data = $row->category;
        return $data;
    }
}

When I run debug is error is: Call to undefined function query() in line..., How to fix it?

  • 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-03T22:03:17+00:00Added an answer on June 3, 2026 at 10:03 pm

    You can change function query -> query1

    function query1($sql) { 
            $this->query = mysql_query($sql); 
            if(!$this->query) { 
                echo "Error: " . mysql_error(); 
                exit; 
            } 
        } 
    

    And then:

    function get_data($category_id) { 
            $sql = 'SELECT id, name FROM category WHERE id='.$category_id; 
            $this->query1($sql); // Error has repair
            $row = mysql_fetch_object($query); 
            $data = $row->category; 
            return $data; 
        } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this sample code for async operations (copied from the interwebs) public class
I have this code sample: class Number { int i; public: Number(int i1): i(i1)
I have the following simple Java code: package testj; import java.util.*; public class Query<T>
Take this sample code: Class Foo ReadOnly name As String Public Sub New(name As
I have a sample code below. #include<iostream> template<typename T> class XYZ { private: T
I have defined some models like this (Entity Framework Code-First): public class A {
Using VS2010, .NET4.0, MVC3, EF4.1 Code-First I have this POCO entities: public class XBLContent
I have the following simple code abstract class A { public abstract void Test(Int32
I have a simple code below: import java.util.ArrayList; public class BoidList extends ArrayList {
I have a very simple code: package mygame; public class RunGame { public static

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.