0

While i execute following code:

$db_host = "<IP>";  // Host name
$db_user = "<usr>";  // User name of your database
$db_password = "<pass>";     // Password of your database
$db_name="<db name>";   // Database name

$con = mysql_connect($db_host,$db_user,$db_password);
mysql_select_db($db_name) or die("Cannot select database...");

It shows following errors:

Warning: mysql_connect() [function.mysql-connect]: OK packet 6 bytes shorter than expected in C:\wamp\www\limosbusesjets\connection.php on line 21

Warning: mysql_connect() [function.mysql-connect]: mysqlnd cannot connect to MySQL 4.1+ using old authentication in C:\wamp\www\limosbusesjets\connection.php on line 21 Cannot select database...

Linger
  • 14,942
  • 23
  • 52
  • 79
Mayan Alagar Pandi
  • 141
  • 5
  • 6
  • 13

1 Answers1

3

These errors generally happen when one is using PHP 5.3, and its new mysqlnd driver to connect to MySQL (which is often the case with PHP 5.3, as it's one of the new stuff introduced with 5.3 -- and "mysqlnd" is mentionned in your second error) : with those, you cannot connect to a MySQL database using the old-passwords system.

Which means you'll have to change the way your MySQL server deals with passwords, to switch to the "new" authentication system.

See, for instance :

Not sure it's what is causing the problem in your case, but that's one common MySQL related thing, with PHP 5.3, for those errors...

Community
  • 1
  • 1
Pascal MARTIN
  • 395,085
  • 80
  • 655
  • 663