<?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();
}
}
};
?>
Asked
Active
Viewed 522 times
-4

Nikolay Mihaylov
- 3,868
- 8
- 27
- 32

D. N.
- 1
- 2
-
You put in the right host / user / password combination? – Jonnix Jun 15 '16 at 14:53
-
1Welcome to SO. Please ask your question within the body and format your code. – etalon11 Jun 15 '16 at 14:53
-
1Possible 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 Answers
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