Jump to content

mysql_connect


dagoodgames

Recommended Posts

Hello,

I'm trying to connect to a mySQL database with PHP. I'm trying to use the mysql command, but I get the following message:

Warning: mysql_connect(): Access denied for user 'dagoodgamer'@'localhost' (using password: YES) in /home/dagoodga/...etc.

Does this message mean I have the wrong username and/or password? If so, could someone explain the proper way to use the mysql_connect command? I'm not very familiar with it. Is the following the correct usage:

$db = mysql_connect("localhost", "username", "password");

(where you replace "username" and "password" with your username and password?)

Thanks,

DaGoodGames
Link to comment
Share on other sites

you need to make sure you have access two different ways:

First, the user/login needs to be correct
second, the login source needs to be valid

for example, you might be able to login as ROOT/PASSWORD from LOCALHOST, but not as ROOT/PASSWORD from 123.45.6.123

I you want to only allow local access, localhost is appropriate, but if you want to login from other locations, you might specify the IP in your settings, or you could specify % by BE CAREFULL doing that...

Here is how I connect...
[code]
$user="blah";
$host="localhost";
$password="blah";
$database = "blah";
mysql_connect($host,$user,$password);
mysql_select_db($database);
[/code]
Link to comment
Share on other sites

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.