0
votes

The following error occur for my website:

Warning: mysql_connect(): Access denied for user 'mydb_db'@'localhost' (using password: YES) in /home/fiveghr/public_html/don/dbconnection/connection.php on line 8 Could not connect: Access denied for user 'mydb_db'@'localhost' (using password: YES)

<?php
$rpath = $_SERVER["DOCUMENT_ROOT"];
require $rpath."/don/dbconnection/config.php"; 
class getdbconnection {
    public function getConnection(){
        //      $con = mysql_connect("localhost","*****","******");
        $con = mysql_connect(DB_HOST,DB_USER,DB_PASSWORD);
        if (!$con)
        {
            return die('Could not connect: ' . mysql_error());
        } else {
            //          mysql_select_db("real_state", $con);
            mysql_select_db(DB_NAME, $con);
            //return $con;
        }
    }
} 
?>
1
You should find as mysql in your cpanel, there you shall create the db, username and passwordSulthan Allaudeen
you should never share your database password online. Please try to use ***** in place of passwordNishant Nair
but i want to know how to solve this issue..?heart hacker
Did you create this database and user already?RST
yes my website working already for last 2 yrs without any problem but now unfortunately this error occurs@RSTheart hacker

1 Answers

1
votes

Value of DB_HOST must be the server address as "http://www.myserver.com" not localhost