I use this code for update a record in mysql
This is my code:
$result in this case is just a resource, it does not contain the reason.
For other type of SQL statements, INSERT, UPDATE, DELETE, DROP, etc, mysql_query() returns TRUE on success or FALSE on error.
Source: PHP Manual
So you can only get TRUE / FALSE from it in your update query. It won't tell you the reason. But as you said it happens when your server is overcrowded so reason probably is "too many connections"
If mysql_query returned NULL, then that would be a bug on PHP. How do you know that it is actually returning NULL?
For update statements mysql_query should only return TRUE or FALSE. So your error checking code is fine. As to finding out what went wrong, you will have to call other function - mysql_error() would give you a blurb about what went wrong. So print the value of mysql_error() inside your false block. Like this:
echo 'failed. SQL Err: '. mysql_error()
Do that and you will probably get a clue to as to how 'record got updated, but return value is false'. It should not have happened.