When I try and run the website I have 2 ways of opening the MYSQL database connection.
I am using cPanel to load MySQL database and files.
If I use PDO it works fine.
But if I use mysql_connect I get the message Access denied for user 'randyphp_tech'@'localhost' to database '_fred'
Here is my code below
$config_db = array (
'host' => 'localhost', // MySQL database Hostname, usually localhost
'username' => 'randyphp_tech', // MySQL database username
'password' => 'mzlapq01', // MySQL database password
'dbname' => 'randyphp_fred' // MySQL database name
);
$db = new PDO('mysql:host='.$config_db['host'].';dbname='.$config_db['dbname'].'', $config_db['username'], $config_db['password']);
echo "<p>PDO works</p> ";
$con = mysql_connect("localhost", $config_db['username'], $config_db['password']);
Our community of experts have been thoroughly vetted for their expertise and industry experience.