-4
<?php
class MySQLDB 
{
    var $connection; //The MySQL database connection
    var $num_active_users; //Number of active users viewing site
    var $num_active_guests; //Number of active guests viewing site
    var $num_members; //Number of signed-up users

    function MySQLDB() {
        $this->connection = mysql_connect(DB_SERVER, DB_USER, DB_PASS) or die(mysql_error());
        mysql_select_db(DB_NAME, $this->connection) or die(mysql_error());

        $this->num_members = -1;

        if (TRACK_VISITORS) {
            $this->calcNumActiveUsers();
            $this->calcNumActiveGuests();
        }
    }
};
?>
Nikolay Mihaylov
  • 3,788
  • 8
  • 25
  • 32
D. N.
  • 1
  • 2
  • You put in the right host / user / password combination? – Jonnix Jun 15 '16 at 14:53
  • 1
    Welcome to SO. Please ask your question within the body and format your code. – etalon11 Jun 15 '16 at 14:53
  • 1
    Possible duplicate of [MySQL ERROR 1045 (28000): Access denied for user 'bill'@'localhost' (using password: YES)](http://stackoverflow.com/questions/10299148/mysql-error-1045-28000-access-denied-for-user-billlocalhost-using-passw) – bcmcfc Jun 15 '16 at 14:54

1 Answers1

0

Use this code:

$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "myDB";

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
} 

And make sure you type in the RIGHT username, password and database name... :)

CoderYordi
  • 57
  • 9