If the $result from the previous line is false, then wouldn't the $row not be set then?
For $result to be false, it means that the database connection failed, or the correct database was not selected, or the SQL statement was incorrect. If any of these are true, then then mysqli_fetch_row($result) is a mistake to begin with.
As such, instead of checking if $row is set, you should check the number of rows returned (and check that $result is not false to begin with), or change the query to select COUNT(*) instead.
By the way, since you are using the MySQLi extension, you should escape with mysqli_real_escape_string(), not mysql_real_escape_string(). Better yet, you could use prepared statements.