As far as I can tell my script works fine but I wanted to check that I had written it in the right way. Thanks.
$sql = "SELECT email FROM user WHERE username = '$username'";
error("A database error occurred in processing your ".
"request.\\nIf this error persists, please ".
$query = mysql_query($sql, $db);
// Check the database to see if anything matches the entered details.
$number_of_matches = @mysql_num_rows($query);
// If there is a matching entry, reset and send the password
if($number_of_matches >= '1')
$result = mysql_fetch_object($query);
$mail_to = $result->email;