woozy Posted November 26, 2005 Share Posted November 26, 2005 I'm actually embarrassed to post this question because it is so general and vague but... well, I'm stumped I recently had to reinstall PHP (4.4.1. for windows) and Mysql Server (4.1) and, well, I can't get a php connect and that is *all* I know. I've written: $db_user = 'webreader'; $db_password = 'w4reed'; $database = 'sirentiger'; $db_host = 'localhost'; $q = DB::connect("mysql://$user:$password@$host/$database"); if (DB::isError($q)){ die($q->getMessage(); } And all I get is a simple message "DB Error: connect failed " And that's it! I've tried rewriting the connect command to use the root account and a variaty of other options. I wouldn't feel so bad trying to debug but I'm not getting *any* response at all. Nothing shows up in the Web Server errer logs, nor in the MySql server error logs or anything. What can I do to trouble shoot? I don't have any idea why it's failing to connect and the message "DB Error: connect failed " is not very informative. Any help appriciated! Thanks. Quote Link to comment Share on other sites More sharing options...
woozy Posted November 26, 2005 Author Share Posted November 26, 2005 Oops. I just notice my variable names don't match in the above post. That *not* the problem. I still don't connect with the right variable names. Quote Link to comment Share on other sites More sharing options...
neylitalo Posted November 26, 2005 Share Posted November 26, 2005 Assign your database connection string to a variable, echo it, and let us know what the result is. And I'm assuming that the DB library is installed by the way it generated the error. Quote Link to comment Share on other sites More sharing options...
woozy Posted November 26, 2005 Author Share Posted November 26, 2005 [!--quoteo(post=322108:date=Nov 25 2005, 09:12 PM:name=neylitalo)--][div class=\'quotetop\']QUOTE(neylitalo @ Nov 25 2005, 09:12 PM) 322108[/snapback][/div][div class=\'quotemain\'][!--quotec--] Assign your database connection string to a variable, echo it, and let us know what the result is. And I'm assuming that the DB library is installed by the way it generated the error. I'm not sure what you mean by "connection string" but I rewrote to code as: function get_db($host, $database, $user, $password){ require_once('DB.php'); $q = DB::connect("mysql://$user:$password@$host/$database"); echo "Database connection: $q<br>\n"; $q_array = get_object_vars($q); foreach ($q_array as $k => $v){ echo "\$q[$k] = $v<br>\n"; } echo (DB::connect("mysql://$user:$password@$host/$database")); if (DB::isError($q)){ die($q->getMessage()." $user $password $host $database");} return $q; } and it echoed out: Database connection: Object $q[error_message_prefix] = $q[mode] = 1 $q[level] = 1024 $q = -24 $q[message] = DB Error: connect failed $q[userinfo] = [nativecode=Can't connect to MySQL server on 'localhost' (10061)] ** mysql://webreader:reading@localhost/sirentiger $q[backtrace] = Array $q[callback] = ObjectDB Error: connect failed webreader reading localhost sirentiger I'm a bit confused by what the "10061" is supposed to mean. Is that a port number? If so it's the wrong one and I'm not sure where it got that number from. If so I guess that would be the first place to look. What do you think? Thanks for your help. Quote Link to comment Share on other sites More sharing options...
woozy Posted November 26, 2005 Author Share Posted November 26, 2005 Oops again. The above result was when I had somehow turned of my MySQL service. *This* is what I get Database connection: Object $q[error_message_prefix] = $q[mode] = 1 $q[level] = 1024 $q = -24 $q[message] = DB Error: connect failed $q[userinfo] = [nativecode=Client does not support authentication protocol requested by server; consider upgrading MySQL client] ** mysql://webreader:reading@localhost/sirentiger $q[backtrace] = Array $q[callback] = ObjectDB Error: connect failed webreader reading localhost sirentiger Soooooo, I guess I better look into authentication protocol and turning it off (or figuring out how to turn it on in php)? Quote Link to comment Share on other sites More sharing options...
woozy Posted November 26, 2005 Author Share Posted November 26, 2005 Cool. Solved it! This'll be an issue with MySQL 5 but seems to also be an issue with MySQL > 4.1 (I'm using 4.4.1) MySQL changed the password hashing method from 16 byte to 32 byte encryption. DB.php doing the mysql::user:password@host, uses the old 16 byte encryption. What I did was change the password in MySql using the OLD_PASSWORD() (as opposed to PASSWORD()) function, and change my password to be less secure but PHP compatible. [a href=\"http://dev.mysql.com/doc/refman/5.0/en/old-client.html\" target=\"_blank\"]http://dev.mysql.com/doc/refman/5.0/en/old-client.html[/a] has all the answers. Thanks for pointing me in the right direction! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.