Jump to content

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?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.