When using the mysql_ping command under php 5.1.2 and mysql 5.0, I was having problems with the auto-reconnect "feature", mainly that when the connection was severed, a mysql_ping would not automatically re-establish the connection to the database.
The connection to the DB is dropped when the time without a query excedes the wait_timeout value in my.cnf. You can check your wait_timeout by running the query "SHOW VARIABLES;"
If you're having problems auto-reconnecting when the connection is dropped, use this code:
<?php
$conn = mysql_connect('localhost','user','pass');
mysql_select_db('db',$conn);
if (!mysql_ping ($conn)) {
mysql_close($conn);
$conn = mysql_connect('localhost','user','pass');
mysql_select_db('db',$conn);
}
?>