...

View Full Version : connecting to mysql database



steviecee
06-22-2005, 10:03 AM
Hi i'mhaving real trouble getting a connection to a mysql database i need to query. the connection script is below:

<?php


DEFINE ('DB_USER', "****");
DEFINE ('DB_PASSWORD', "********");
DEFINE ('DB_HOST',"localhost");
DEFINE ('DB_NAME', "yorkshire");

//connect to mysql

$db_connection=mysql_connect(DB_HOST,DB_USER,DB_PASSWORD);

//select the database

mysql_select_db(DB_NAME);

?>

the errors are:

Warning: mysql_connect(): Client does not support authentication protocol requested by server; consider upgrading MySQL client in C:\Server\Apache2\mysql_connect_york.inc on line 17

Warning: mysql_select_db(): Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\Server\Apache2\mysql_connect_york.inc on line 21

Warning: mysql_select_db(): A link to the server could not be established in C:\Server\Apache2\mysql_connect_york.inc on line 21

I'm totally baffled, any ideas?

cheers
Steve

Digger3000
06-22-2005, 10:08 AM
I just do


mysql_connect();
mysql_select_db("yorkshire");

steviecee
06-22-2005, 10:13 AM
would that be in the php script you are using to query? If so you won't need a seperate connecting script?

steve

Yakisoba
06-22-2005, 10:27 AM
Not sure if this will help, but this is what I do to get a connection...



<?php

//variables
$db_host = "localhost";
$db_user = "XXXXXX";
$db_pass = "XXXXXX";
$db_name = "yakisoba";
$db_table = "noodle";

//connect to mysql
mysql_connect($db_host, $db_user, $db_pass) or die ("Connection to mySQL failed");

//select the database using $db_name
@mysql_select_db("$db_name") or die ("Unable to locate: $db_name");

?>


its pretty similar to what you did but without the DEFINE.

Also, might be a good idea to make sure your php.ini is set up right ([MySQL] section)...I got screwed once not paying attention to php.ini settings.

Yak

steviecee
06-22-2005, 11:04 AM
cheers for that, got rid of two of the errors, but still leaving the nasty one,
ie
Warning: mysql_connect(): Client does not support authentication protocol requested by server; consider upgrading MySQL client in C:\Server\Apache2\mysql_connect_york.inc on line 17
Connection to mySQL failed

line 17 is:
mysql_connect($db_host, $db_user, $db_pass) or die ("Connection to mySQL failed");

I'm starting to think it is the php.ini file although i've looked at this and can't see anything wrong....ideas??
steve

Yakisoba
06-22-2005, 11:29 AM
You're right, that is nasty...I never seen that one before.

Personally I don't know the solution to that error, but I was able to find somthing that might help.

Check this out:
http://forums.mysql.com/read.php?11,6400,10611#msg-10611

not sure but this may help you as well...
http://dev.mysql.com/doc/mysql/en/old-client.html

Yak

steviecee
06-22-2005, 11:48 AM
thanks for all your help yakisoba, I've already been through the first link,but it didn't work. i'll go through the second link. thanks for all your help with this, if anyone else has any ideas i'm all ears!!!
cheers
steve

steviecee
06-22-2005, 01:41 PM
Thanks a lot for that last link, it worked a treat! :thumbsup:
thanks to everyone for their help it really is appreciated!
steve



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum