查询使我的页面无法响应

I am not sure why but my MySQL query below, makes my page not respond and I get that box saying this page has became unresponsive. I am wondering what would be the easiest way to make sure that this does not happen.

public function audioplayer($id)
{
    $r_hostname = "192.***.**.***";
    $r_username = "c**";
    $r_password = "*******";
    $link = mysql_connect($r_hostname,$r_username,$r_password);

    $a_hostname = "192.168.***.***";


    $db = mysql_select_db('asterisk', $link);

    $result = mysql_query("SELECT * FROM recording_log WHERE start_time LIKE '".date("Y-m-d")."%' AND filename LIKE 'IL_%-%". $id ."' LIMIT 3",$link);


    #$result = mysql_query("select * from recording_log WHERE filename LIKE 'IL_%-%".$id."'",$link);

    if (!$result) {
            die('Invalid query: ' . mysql_error());
    }   
    if($result != '')
    {
        while($row = mysql_fetch_array($result, MYSQL_ASSOC)){
            foreach($row as $column => $value) {
                $array[type] ="wav";    
                $array[$column]= $value;
            }
        }
    }
    else {
        $linktwo = mysql_connect($a_hostname,$r_username,$r_password);

        $dbtwo = mysql_select_db('asterisk', $linktwo);

        $resulttwo = mysql_query("SELECT * FROM recording_log WHERE start_time LIKE '".date("Y-m-d")."%' AND filename LIKE 'IL_%-%". $id ."' LIMIT 3",$linktwo);

        while($row = mysql_fetch_array($resulttwo, MYSQL_ASSOC)){
            foreach($row as $column => $value) {
                $array[type] ="mp3";
                $array[$column]= $value;
            }
        }
    }
    return json_encode($array);
}

Feels like there's a syntax error here:

$array[type] ="mp3";

Did you mean:

$array[$type] ="mp3";
$array["type"] ="mp3";

Please, don't use mysql_* functions in new code. They are no longer maintained and are officially deprecated. See the red box? Learn about prepared statements instead, and use PDO, or MySQLi - this article will help you decide which. If you choose PDO, here is a good tutorial.