Idarac
asked on
Access denied for user 'randyphp_tech'@'localhost' to database '_fred'
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']);
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
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_
echo "<p>PDO works</p> ";
$con = mysql_connect("localhost",
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Both of these lines will work
$db = new PDO('mysql:host='.$config_
echo "<p>PDO works</p> ";
// OPEN A CONNECTION TO THE DATA BASE SERVER AND SELECT THE DB
$mysqli = new mysqli($config_db['host'],