Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2014-01-28
8
Medium Priority
?
451 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 1000 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
Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

 
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 84

Assisted Solution

by:Dave Baldwin
Dave Baldwin earned 1000 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 84

Expert Comment

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

Featured Post

Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

Question has a verified solution.

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

3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
This article shows the steps required to install WordPress on Azure. Web Apps, Mobile Apps, API Apps, or Functions, in Azure all these run in an App Service plan. WordPress is no exception and requires an App Service Plan and Database to install
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

721 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