PHP & MySQL: The Missing Manual
Example 8-1
SQL Connection test