Posted by Terryy, 07-19-2008, 06:15 AM | Hi I need some help as i dun really know anything about database and I get this error on my website "Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'root'@'localhost' (using password: YES) in /home/msadmin/public_html/includes/connect.php on line 12
Cannot establish connection to MySql Server."
and this is my connect.php file "
|
Posted by Epiphany21, 07-19-2008, 07:48 AM | Try this:-
In the original code you didn't specify the given variables to connect to the DB. Also, I would try and use another account other than root.
|
Posted by The Universes, 07-19-2008, 09:32 PM | The error message you got meant the password is incorrect for the mysql user you specified in the mysql_connect.
|
Posted by Epiphany21, 07-20-2008, 02:55 AM | He didn't even set the variables.
|
Posted by Terryy, 07-20-2008, 07:08 AM | Okie i created a database in my cpanel and added an user account with all permissions enable to it
But I dunnoe why i still get the same error msg, anyone can enlighten me?? thx
|
Posted by Epiphany21, 07-20-2008, 07:12 AM | That's because you did this.
After that, you have an 'or die.. and everytime it's going to die if you have it setup like that. I'm not 100% sure, but I'm pretty sure that's invalid.
Use this code.
|
Posted by bear, 07-20-2008, 08:27 AM | Username is incorrect. On a cPanel server, it's just like you have for the database name: "msadmin_maple", so in this case it would be "msadmin_user", where "user" is the actual database user name.
Last edited by bear; 07-20-2008 at 08:43 AM.
Reason: Corrected
|
Posted by Epiphany21, 07-20-2008, 08:31 AM | Bear, are you saying if your username on a Cpanel is BLAH, that connecting via mysql the username you use is BLAH_BLAH?
If so, since when? I've never had to do that on a cPanel server. It's something new they did?
|
Posted by bear, 07-20-2008, 08:41 AM | It's not new. Cpanel, for as long as I've been using it, has used the username you create as "user" and appended the account username like so: cpaneluser_dbusername. DBname is the same way.
If you choose a db name of "stuff", and a db username of "admin", and your cpanel account is "myaccount", then the connection info would be:
$db_user = 'myaccount_admin';
$db_pass = '1234';
$database = 'myaccount_stuff';
Last edited by bear; 07-20-2008 at 08:44 AM.
|
Posted by Epiphany21, 07-20-2008, 08:55 AM | I got you. I thought you were referring to the database username, rather than the db name. I was confused, because in his code he already has it setup the way we knew the 'cpanel' stuff should work. My mistake bear.
|
Posted by Terryy, 07-21-2008, 05:24 AM | I upload two screenshots so you all know what i doing:
http://img295.imageshack.us/my.php?image=stage1xf3.jpg
http://img516.imageshack.us/my.php?image=stage2pz3.jpg
When i do this, i still get the same error msg and also i dont get you what you mean by invalid of the $db_host= etc. i typed?? can enlighten further? thanks
|
Posted by Epiphany21, 07-21-2008, 05:35 AM | You're forgetting the password in this line. Replace that line with.
|
Posted by Terryy, 07-22-2008, 08:18 AM | It dosent work....by the way, shld i put anything on the line that contains $db_host etc. ?? can anyone show me any example database php file they created??
|
Posted by Epiphany21, 07-22-2008, 11:09 AM | This is from php.net This works.
That line, you need to change the mysql_user, and the mysql_password to your database username and password.
Change foo to your database name.
|
|
Add to Favourites
Print this Article |