Current location: Hot Scripts Forums » Programming Languages » PHP » help pleeease...Warning: mysql_connect() [function.mysql-connect]: Access denied for user

help pleeease...Warning: mysql_connect() [function.mysql-connect]: Access denied for user

Reply
  #1 (permalink)  
Old
Newbie Coder
 
Join Date: Dec 2008
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
help pleeease...Warning: mysql_connect() [function.mysql-connect]: Access denied for user

Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'root'@'localhost' (using password: YES) in /home/.../public_html/enhu.com/includes/connection.php on line 5
Database connection failed: Access denied for user 'root'@'localhost' (using password: YES)

i also download the error_log and it says:

PHP Warning: mysql_connect() [<a href='function.mysql-connect'>function.mysql-connect</a>]: Access denied for user 'root'@'localhost' (using password: YES) in /home/.../public_html/....com/includes/connection.php on line 5

i've been solving the issue since last night. how can i fix the error?

here is the connection.php

Quote:
<?php
require("constants.php");

$connection = mysql_connect(DB_SERVER,DB_USER,DB_PASS);
if (!$connection) {
die("Database connection failed: " . mysql_error());
}

$db_select = mysql_select_db(DB_NAME,$connection);
if (!$db_select) {
die("Database selection failed: " . mysql_error());
}
?>

Last edited by benicio; 12-19-08 at 08:44 AM.
Reply With Quote

Featured Marketplace Scripts (view more)

  #2 (permalink)  
Old
Yeroon's Avatar
Code Master
 
Join Date: Aug 2007
Location: Netherlands, Nijmegen
Posts: 850
Thanks: 2
Thanked 24 Times in 23 Posts
are you sure you have the right username and password? Check the constants.php file. Think they are in there.
__________________
Feel free to thank people if they help you by clicking thanks at a post.
=================================
Make it idiot proof and someone will make a better idiot.
=================================
Realise the impotence of proof reading everything you publish
Reply With Quote
  #3 (permalink)  
Old
DAL's Avatar
Code Master
 
Join Date: Jun 2003
Location: North East England/UK
Posts: 874
Thanks: 0
Thanked 1 Time in 1 Post
I spent about half an hour last time I installed phpmyadmin trying to get it working with that error message. I googled it trying to see if there was something else causing it and in the end it turned out that I did infact have the wrong password, save yourself more time and look it up

Like Yeroon said (it's my turn to agree with you Yeroon ) check the constants.php or just strip the DB_USER and DB_PASS out and replace it with string values;

PHP Code:

<?php
require("constants.php");

$connection mysql_connect(DB_SERVER,"whatIthinkmyusernameis","whatIthinkmypasswordis");
if (!
$connection) {
die(
"Database connection failed: " mysql_error());
}

$db_select mysql_select_db(DB_NAME,$connection);
if (!
$db_select) {
die(
"Database selection failed: " mysql_error());
}
?>
Remember to replace them variables once you figure out the password or where the password is as you may want to keep that stuff inside constants.php;
__________________
"once upon a midnight dreary, while i pron surfed, weak and weary, over many a strange and spurious site of 'hot xxx galore'. While i clicked my fav'rite bookmark, suddenly there came a warning, and my heart was filled with mourning, mourning for my dear amour," 'Tis not possible!", i muttered, "give me back my free hardcore!" quoth the server, 404."
Reply With Quote
  #4 (permalink)  
Old
Newbie Coder
 
Join Date: Dec 2008
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
i'm pretty sure its right. i spell it right. i check this almost evrytime i upload the files since i kept trying if i can see the pages till now and still the same error that i get.

this is my code:

Quote:
<?php

define("DB_SERVER", "localhost");
define("DB_USER", "root");
define("DB_PASS", "*************");
define("DB_NAME", "enhu");

?>
dyou think i has something to do with the host?
Reply With Quote
  #5 (permalink)  
Old
DAL's Avatar
Code Master
 
Join Date: Jun 2003
Location: North East England/UK
Posts: 874
Thanks: 0
Thanked 1 Time in 1 Post
the require() might be better just making that include() for now since it wont check for new values each time...

Or do what I suggested with the direct input until you have it sorted. I can almost gaurantee that its dbname, username or password problem

Kind regards
Dal
__________________
"once upon a midnight dreary, while i pron surfed, weak and weary, over many a strange and spurious site of 'hot xxx galore'. While i clicked my fav'rite bookmark, suddenly there came a warning, and my heart was filled with mourning, mourning for my dear amour," 'Tis not possible!", i muttered, "give me back my free hardcore!" quoth the server, 404."
Reply With Quote
  #6 (permalink)  
Old
Newbie Coder
 
Join Date: Dec 2008
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
i have also tried to put directly the variables in the connection.php and same error.

could it be the db_name. i've create a database named enhu in database wizard but the database name appear in phpmyadmin was "host"_enhu

could this be the cause?
Reply With Quote
  #7 (permalink)  
Old
DAL's Avatar
Code Master
 
Join Date: Jun 2003
Location: North East England/UK
Posts: 874
Thanks: 0
Thanked 1 Time in 1 Post
hmmm not sure - worth a try, I dont have the word "host_" before my off-line db

Remember to mark your post solved if this worked, too many open threads around here

If not get back, I'm sure you'll get to the bottom of it.

did you install from a package such as xampp?
__________________
"once upon a midnight dreary, while i pron surfed, weak and weary, over many a strange and spurious site of 'hot xxx galore'. While i clicked my fav'rite bookmark, suddenly there came a warning, and my heart was filled with mourning, mourning for my dear amour," 'Tis not possible!", i muttered, "give me back my free hardcore!" quoth the server, 404."
Reply With Quote
  #8 (permalink)  
Old
Newbie Coder
 
Join Date: Mar 2005
Location: Orlando, Florida
Posts: 77
Thanks: 0
Thanked 0 Times in 0 Posts
Might also want to make sure the user has been granted privileges for the database in question.
__________________
BlueScripts - Free PHP Scripts
Reply With Quote
  #9 (permalink)  
Old
Aspiring Coder
 
Join Date: Jul 2006
Location: United Kingdom
Posts: 413
Thanks: 12
Thanked 3 Times in 3 Posts
looking at this i would tell you to check your username your password ect. change them on the server to something else what package did u use or is this on a host :S ? and i know your using localhost but if this isnt your server do you have root access ?

thanks and good luck
mike
Reply With Quote
  #10 (permalink)  
Old
Newbie Coder
 
Join Date: Dec 2008
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
i do have the root access.

when i get here: [ C:\wamp\bin\mysql\mysql5.0.51b\bin\mysql.exe ]
the prompt issued this error when trying my password.

- > ERROR 1044(42000) Access denied for user ''@'localhost' to database 'mysql'

but if i use the mysql console in wampserver2.0. it works fine.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Warning: mysql_query() [function.mysql-query]: Access denied for user 'mylogi'@'localhost' (using pa tut123408 PHP 6 05-27-08 11:50 PM


All times are GMT -5. The time now is 08:12 PM.
vBulletin® Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.