On 1/12/2013 1:28 PM, Rick Dwyer wrote:
On Jan 12, 2013, at 3:56 PM, "admin" <admin@xxxxxxxxxxxxxxxxxxx> wrote:
-----Original Message-----
From: Rick Dwyer [mailto:rpdwyer@xxxxxxxxxxxxx]
Sent: Saturday, January 12, 2013 8:26 AM
To: php-general@xxxxxxxxxxxxx
Subject: Can't connect to MySQL via PHP
Hello all.
I used the code below successfully to connect to a MySQL db on one
hosting provider. I've moved the code to a new hosting provider with
new values and it returns:
Access denied for user 'user'@'db.hostprovider.net' (using password:
YES)
Even though I can copy and paste these three values (host, user and
pass) and paste into Navicat to make a connection. So the credentials
are correct, but they are not authenticating when used in PHP. I've
tried making host "localhost" and "127.0.0.1". both with the same
result.
Can someone tell me what I am doing wrong here?
Appreciate it.
Thanks,
--Rick
$db_name = "mydb";
$vc_host = "db.hostprovider.net";
$vc_user = "user";
$vc_pass = "pass";
$connection = @mysql_connect($vc_host, $vc_user, $vc_pass); $db =
mysql_select_db($db_name, $connection);
echo mysql_error();
--
PHP General Mailing List (http://www.php.net/) To unsubscribe, visit:
http://www.php.net/unsub.php
Try this for me
-----------------------------------------------------------
$db = mysql_connect($vc_host, $vc_user, $vc_pass);
mysql_select_db($db_name, $db);
if (!$db) {
die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
mysql_close($db);
Could not connect: Access denied for user 'user'@'localhost' (using password: YES)
Using mysqli_ returns the same error message as well.
--Rick
--Rick
Isn't that just telling you that the uid is not defined for the proper
access to any mysql db? It's been awhile since I set my accesses up so
I can't remember. I have one user that I use to do all my connections
with. That user is declared for each db with full access.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php