PDA

View Full Version : [PHP] mysql_connect


tattekudasai
09-24-2008, 07:57 AM
What are the parameters for mysql_connect?

mysql_connect($host,$user,$pass);

I've tried mysql_connect("localhost",$dbname,$dbpass) but authentication fails :(

UnlimitedMB
09-24-2008, 08:00 AM
The server is mysql not localhost.

ckpd
10-06-2008, 04:56 PM
I use "localhost" and it works fine for me. Well at least i think it does.

Tyler
10-06-2008, 04:58 PM
I use "localhost" and it works fine for me. Well at least i think it does.
It wont work if you use localhost on our servers. It is not possible, there is no mysql server on "localhost".

ckpd
10-06-2008, 06:13 PM
Okey doke i just found that out however, ive tried mysql and it still wouldnt work.

Example of my code:

$host = 'mysql'; $user = 'me'; $pass = 'me'; $db = 'mydb';
mysql_connect($host,$user,$pass)or die('Cannot connect');
mysql_select_db($db);

This returns the error "Cannot connect".

When i forced a MySQL ERROR eg:

mysql_connect(infoHere)or die(mysql_error());

i got:

Access denied for user 'mydb'@'localhost' (using password: YES)

UnlimitedMB
10-06-2008, 06:15 PM
If you are getting an error that says localhost then you are not using the correct server.
The mysql server is "mysql" not "localhost"

ckpd
10-06-2008, 07:11 PM
If you are getting an error that says localhost then you are not using the correct server.
The mysql server is "mysql" not "localhost"

I have tried both and neither have worked and even thought the error says:

@ 'localhost'

I havnt put localhost as the $host variable

UnlimitedMB
10-06-2008, 07:46 PM
You must have, there is no way the error could say localhost if you put mysql.

Victor01469
10-06-2008, 08:27 PM
Be sure you are not confusing host with database type.

Both should be defined as "mysql" without the quotes.