mysql fetch row and undefined variable error : I keep getting the following errors.  The $query produces a 1300 result list.  When I echo $query I get the mysql statement.

[25-Aug-2016 21:38:32 America/New_York] PHP Warning:  mysql_fetch_row() expects parameter 1 to be resource, null given in song.php on line 285
[25-Aug-2016 21:38:32 America/New_York] PHP Notice:  Undefined variable: song_hash in song.php on line 292

    $query = "select " . $query_data . " from " . $query_tables . " where " . $query_where;
    //echo $query;
    $result = mysql_query($query,$database);
    
    while($row = mysql_fetch_row($result)){
    
    	$key = $row[0];
    	$song_hash[$key] = ($song_hash[$key] + 1);	
    	
    }
    
    $largest = max($song_hash);