Solved

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

Posted on 2014-01-28
8
447 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
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 
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

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
converting integer data type to time data type in sql 4 44
MYSQL responding very slow 3 48
Php - How to get the value of json file using PHP? 29 57
JSON decode 5 15
Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
Creating and Managing Databases with phpMyAdmin in cPanel.
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 dynamically set the form action using jQuery.

735 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