Jump to content

mysql_connect not connecting - on 2 different servers


peter_anderson

Recommended Posts

I'm having difficulty connecting to the DB.

 

My information is correct (and copied from the cPanel) and on 2 different testing servers, it failed.

 

Error:

Warning: mysql_connect() [function.mysql-connect]: Access denied for user '****'@'localhost' (using password: YES) in /*/install.php on line 10

Access denied for user '*****'@'localhost' (using password: YES)

(sensitive info removed)

 

Here's the install script:

<?php

require_once("config.php");

$sql = mysql_connect($host, $user, $pass) or die(mysql_error());
mysql_select_db($db) or die(mysql_error());

//queries removed

echo 'Install complete. Remove this file now!!';

 

Heres config.php

 

<?php

//db
$host = 'localhost';
$user = 'username';
$pass = 'pass';
$db = 'db';
?>

 

Can anyone help? It's probably a small mistake.

 

Thanks :)

Link to comment
Share on other sites

Common mistake with cPanel is the database name and username have an account name prefix.. ie

 

My account is MadTechie, I create a database called 'jobs', I then create a User called 'Techie' password '123' then I assign him to the jobs database (full access)

 

I assume thats where your at now..

 

now to connect

Now my database name is 'MadTechie_jobs',

username is 'MadTechie_Techie',

password is '123'

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.