error connecting to sql host

liunx

Guest
I keep getting an error message when trying to connect to MySQL server. Here is the code I'm using:

<?

$dbhost = 'localhost';
$dbusername = 'correct username';
$dbpasswd = 'correct password';
$database_name = 'correct database name';


$connection = mysql_pconnect("$dbhost","$dbusername","$dbpasswd")
or die ("Couldn't connect to server.");

$db = mysql_select_db("$database_name", $connection)
or die("Couldn't select database.");
?>

And this is the error I keep getting:

Warning: mysql_pconnect(): Access denied for user: 'correct username@localhost' (Using password: YES)
Couldn't connect to server.

I changed the username and password for obvious reasons but I know that I'm using the correct username and password because I rechecked it and connected to the server using the information just as it was typed in the code. Any help in this matter would be greatly appreciated.This means you have the wrong information for connecting to the SQL database, you will need to contact your host.you shouldn't put the variables in quote marks like that.


$connection = mysql_pconnect("$dbhost","$dbusername","$dbpasswd")What is mysql_pconnect() ???

I always use mysql_connect() without the p. Is there any difference???The mysql_pconnect (<!-- m --><a class="postlink" href="http://uk2.php.net/manual/en/function.mysql-pconnect.php">http://uk2.php.net/manual/en/function.m ... onnect.php</a><!-- m -->) function allows a positive persistant connection.Thanks DA, Ive never seen it used before.Originally posted by GreyBoy
Thanks DA, Ive never seen it used before.

No problem, It can be pretty useful.
 
Top