Jump to content

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 :)

The first server is a directadmin one (my own) with localhost as the host.

 

The second one is a cPanel one from a friend with localhost as the host.

 

It's an odd problem - other scripts I've coded work on the directadmin one.

For cpanel , you have to create a username and password, and associate with the database.

 

so u have to include the username and password too along with dbname and hostname

 

I've done that aswell.

 

DirectAdmin doesn't require that.

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'

 

Thanks for the help so far, everyone, but it still isn't working.

 

I've added the username_ before it, and linked DBs (for the cpanel test), but it doesn't work.

 

I've probably spelt something wrong, so I'll have another check

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.