Solved

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

Posted on 2014-01-28
8
435 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
  • 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
 
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
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
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 82

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 82

Expert Comment

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

Featured Post

Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

Join & Write a Comment

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…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

708 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now