Jump to content

Using PHP to connect to MYSQL server


amrithk

Recommended Posts

Hi,

I am new to PHP and MYSQL. I recently installed both PHP and MYSQL (the community edition) on my computer and I have been trying to use PHP to connect to and access MYSQL (instead of using the MYSQL command line).

 

I used the mysql_connect() function on a test script but I am getting the following error message when I test the script.

 

Warning: mysql_connect() [function.mysql-connect]: Access denied for user ' '@'localhost' (using password: YES) in filename on line 10.

 

I understand that I am being denied access because I have not submitted the right credentials. However, I am testing this code on my local computer where I have full privileges. What might be the reasons I am getting this message? What are the possible solutions? Do I need to configure mysql such that it recognizes that I am using it on a local computer?

 

Thanks,

Link to comment
https://forums.phpfreaks.com/topic/54640-using-php-to-connect-to-mysql-server/
Share on other sites

Your username is blank.

 

// original
mysql_connect("localhost"," ","stargate") or die("Could not connect"); 

//mysql_connect($HOST, $USERNAME, $PASSWORD) that is how it should be setup

// corrected
mysql_connect("localhost","stargate", " ") or die("Could not connect"); 

Try that.

I tried different combinations for the function. I entered my username and password, just my username, just my password and did not enter anything but none of these combinations seemed to work.

 

I don;t think its a problem with my username and password because when I type http://localhost on my web browser, I supply the same user name and password to access all the files.

 

What might be the problem?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.