Watch out! Although mysql_errno() supposedly returns the error number from the last MySQL function, if you don't specify a link identifier, it assumes the last link *opened*, NOT the last link *used*.
That means you can actually have mysql_errno() blindly ignore the error caused by the last MySQL function if it didn't use the last opened link.
Here's an example:
$link1 = mysql_connect('localhost', 'user1', 'password1');
$link2 = mysql_connect('localhost', 'user2', 'password2');
// do something wrong using the first link
mysql_select_db('nonexistentdb', $link1);
// if you don't specify the link identifier ...
if (mysql_errno()) {
// the error from the last MySQL function is not reported
echo mysql_errno() . ': ' . mysql_error() . "\n";
}