我不确定为什么,但我的MySQL查询下面,使我的页面没有响应,我得到那个盒子说这个页面已经没有响应。我想知道什么是最简单的方法来确保不会发生这种情况。
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);
}
答案 0 :(得分:1)
感觉这里有语法错误:
$array[type] ="mp3";
你的意思是:
$array[$type] ="mp3";
$array["type"] ="mp3";
Please, don't use
mysql_*
functions in new code。它们不再被维护and are officially deprecated。请参阅red box?转而了解prepared statements,并使用PDO或MySQLi - this article将帮助您确定哪个。如果您选择PDO here is a good tutorial。