Jump to content

[SOLVED] Errr!! a n00bie will kill himself soon!


greaterthanme

Recommended Posts

Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'username'@'localhost' (using password: YES) in /home/admin/public_html/me/NewG/html/setup.php on line 21

Warning: mysql_select_db() [function.mysql-select-db]: Access denied for user 'nobody'@'localhost' (using password: NO) in /home/admin/public_html/me/NewG/html/setup.php on line 22

Warning: mysql_select_db() [function.mysql-select-db]: A link to the server could not be established in /home/admin/public_html/me/NewG/html/setup.php on line 22
Could not connect to database
[hr]
What's the problem here? :S:S
Link to comment
Share on other sites

This is what i have in the setup.php page from lines 15-22

[hr]
//////DATABASE CONFIG, AND CONNECTION
$db[host] = 'localhost';          //DATABASE HOST "Default is localhost"
$db[user] = 'username';    //DATABASE USERNAME
$db[pass] = 'password';        //DATABASE PASSWORD
$db[name] = 'admin_dbname';  //DATABASE NAME

$connect = mysql_connect($db[host],$db[user], $db[pass]);
mysql_select_db("$db[name]") or die ("Could not connect to database");
[hr]

What do I have to add to database.sql?
Link to comment
Share on other sites

Well I would make them all:

$db['host'] = 'localhost';
$db['user'] = 'username';
....

etc just b/c the way you have it is ugly imo :p. If you are sure the credentials are right I would suggest that you echo each of the variables to verify their contents are what you expect. For example:

echo "localhost == " . $db['host'] . "\n";
Link to comment
Share on other sites

Ok, this is PHP/MySQL 101:

FIRST: You must have a MySQL database. Do you? If not, you need to create one. Your hosting provider either a) provides you with some method of creating one, or b) creates one for you, or c) provides you with an address to one

SECOND: That bit of code in your script has to be modified to point to the actual database you are trying to access.

[quote]//////DATABASE CONFIG, AND CONNECTION
$db[host] = 'localhost';          //DATABASE HOST "Default is localhost"
$db[user] = 'username';    //DATABASE USERNAME
$db[pass] = 'password';        //DATABASE PASSWORD
$db[name] = 'admin_dbname';  //DATABASE NAME

$connect = mysql_connect($db[host],$db[user], $db[pass]);
mysql_select_db("$db[name]") or die ("Could not connect to database");[/quote]

Where it says $db[host] = 'localhost'  as an example, you need to make sure that 'localhost' is the actual location of your database. It could be 'mysql.atmyhostproviders.com' or whatever. But, whatever it is, you need to enter it there by replacing the word 'localhost'.

Same with those other variables. I doubt seriously if your database's username is 'username'. Plug in the actual username there. Same goes for the password.

THIRD: EVERY database has a name. Plug that in to the $db[name] = 'admin_dbname' spot.

Then you should be able to connect.
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • 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.