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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T05:04:39+00:00 2026-05-20T05:04:39+00:00

This should be a no brainer, its late and i cant see what i

  • 0

This should be a no brainer, its late and i cant see what i am doing wrong:

MySQL class:

class MySQL
{
public $db;
private $result;

public function __construct ($host, $user, $password, $database)
{
  $this -> connectDB ($host, $user, $password, $database);
}

public function __destruct ()
{
  $this -> breakDB();
}

private function connectDB ($host, $user, $password, $database)
{
  $this -> db = mysql_connect ($host, $user, $password) or die (mysql_error());
  if (is_resource ($this -> db))
  {
    mysql_select_db ($database) or die (mysql_error());
    mysql_set_charset('utf8',$this -> db); 
  }
}

private function breakDB()
{
  if (is_resource ($this -> db))
  {
    mysql_close ($this -> db);
    }
}
}

class using MySQL:

class Scraper {
private $urls_array = array();
private $mysql;

public function __construct ()
{
        $this -> mysql = new MySQL ('xxx', 'xxx', 'xxx', 'xxx');
}
private function getURLs($city=NULL,$provider=NULL) {

    /* Get all URLs to scrape */
    $result = $this -> mysql -> db = mysql_query("SELECT `xxx`,`xxx`,`xxx`, `xxx` FROM `URL` WHERE `xxx` = '1'");
   }
   }

The line i am having probs with is:

$result = $this -> mysql -> db = mysql_query("SELECT `xxx`,`xxx`,`xxx`, `xxx` FROM `URL` WHERE `xxx` = '1'");

I dont know how to use $mysql correctly so it sends the mysql_query to the connection i opened in the constructor? Any help apreciated THANKS!

  • 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-20T05:04:39+00:00Added an answer on May 20, 2026 at 5:04 am

    You just need to rearrange the line a bit:

    $result = mysql_query("SELECT `xxx`,`xxx`,`xxx`, `xxx` FROM `URL` WHERE `xxx` = '1'",
                          $this -> mysql -> db);
    

    I would suggest creating a query method in your MySQL class though and making the db private.

    At its most basic:

    class MySQL {
       private $db;
    
       // ... as before ...
    
       public function query($queryText) {
           return mysql_query($queryText, $this->db);
       }
    }
    

    Of course, using mysqli might be a better idea all round.

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

Sidebar

Related Questions

This should so work. Please tell me I'm doing something wrong. Here's the code:
This should be a no brainer but I have a small mystery with the
I feel like this should be a no brainer, but clearly I'm missing something...
This should be simple - can't figure out where I'm going wrong: We have
This should be simple... class Object: x = 0 y = [] a =
This seems like it should be a no-brainer, but I can't get a WPF
This should be a no-brainer, but I haven't really written any classic ASP code
This should a quick question for some easy rep. I'm doing some PHP Website
This should be basic, but for some reason its not working for me. I
This should be a simple one: I have an observableArray object called To 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.