Solved

php can't connect to db - states no password being used

Posted on 2014-01-28
8
448 Views
Last Modified: 2014-01-28
I have used the code below on another webpage I created that links to another database with no problems.  I have a new page with a new database.  I am 99% sure I added the user correctly to the new database with all the correct permissions (I even selected all permissions just in case).  I deleted the user and re-added, confirming that I am typing the password correctly.

 I get an error saying I am not sending a password, but in the code below, I am sending a password.   Help!!

Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'uniqueda_ed'@'localhost' (using password: NO) in /home/uniqueda/public_html/xtime/config.php on line 22



$db_host = "localhost"; 
$db_name = "dbnameHere";
$db_user = "userNameHere";
$db_word = "passwordHere";

if (!$db_connection = mysql_connect("$db_host", "$db_user", "$db_word"))

Open in new window

0
Comment
Question by:KCTechNet
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
8 Comments
 
LVL 36

Accepted Solution

by:
Loganathan Natarajan earned 250 total points
ID: 39816877
Can you try like this,

if (!$db_connection = mysql_connect("$db_host", "$db_user", "$db_word") or die (mysql_error()) )
0
 

Author Comment

by:KCTechNet
ID: 39816884
no change..  here is the complete output:

Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'uniqueda_ed'@'localhost' (using password: NO) in /home/uniqueda/public_html/xtime/config.php on line 22

NO DB CONNECTION:
1045 Access denied for user 'uniqueda_ed'@'localhost' (using password: NO)

Warning: mysql_select_db() expects parameter 2 to be resource, boolean given in /home/uniqueda/public_html/xtime/config.php on line 31

NO DB SELECTION:
1045 Access denied for user 'uniqueda_ed'@'localhost' (using password: NO)
NO DATA BASE uniqueda_datatracker
0
 

Author Comment

by:KCTechNet
ID: 39816901
i should mention that it worked perfectly in xampp on my pc.  the error occurred when I moved everything to my hosted site.
0
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 
LVL 36

Expert Comment

by:Loganathan Natarajan
ID: 39816916
It clearly says, that access denied for the user created in hosting...

Make sure check whether you have privilege to connect the db for user? also check the host name is appropriate for mysql connect

ref. http://dev.mysql.com/doc/refman//5.5/en/connection-access.html
0
 
LVL 36

Expert Comment

by:Loganathan Natarajan
ID: 39816919
To give privilege for the user, try like this command,

CREATE USER uniqueda_ed@localhost IDENTIFIED BY 'passpass';
grant all privileges on *.* to uniqueda_ed@localhost with grant option;
0
 
LVL 83

Assisted Solution

by:Dave Baldwin
Dave Baldwin earned 250 total points
ID: 39816932
You need to find out what the correct username and host are for your hosted site.  There is no reason to think that they are the same as your WAMP installation unless you made them the same.  Hosting sites often put the MySQL servers on a different machine which means that 'localhost' won't work.   You have to use the host name or IP address to access them.
0
 

Author Comment

by:KCTechNet
ID: 39816952
wow.  I had a dollar sign in the password and it didn't like that.  Removed dollar sign and all was good.  I guess I could escape the $ but thats ok, tired of looking at that page :)
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 39816966
Glad you got it working, thanks for the points.
0

Featured Post

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

These days socially coordinated efforts have turned into a critical requirement for enterprises.
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question