我不断收到一个数组到字符串转换的通知,这似乎是我已经转义(或没有转义)MySQL 语句的方式。如果我不使用 PHP 变量并将数据作为文本放入它可以工作,但使用变量它会显示错误。帮助!:)
function lastBackupStatus($server,$node){
$serverstatus = "";
$i=1;
$result = mysql_query("select
max(case when status LIKE '%Failed%' then scheduled_start end) Last_Failed,
max(case when status LIKE '%Missed%' then scheduled_start end) Last_Missed,
max(case when status LIKE '%Completed%' then scheduled_start end) Last_Completed,
node_name,
schedule_name
from `events_".$server."`
where node_name='".$node."'
group by node_name, schedule_name
ORDER BY last_failed");
$count=mysql_num_rows($result);
if ($count!== 0){
while ($info = mysql_fetch_assoc( $result )){
if($i < $count){
$serverstatus .="";//do nothing
}else{
if($info['Last_Failed'] > $info['Last_Completed']){
if($info['Last_Failed'] > $info['Last_Missed']){
$serverstatus .="Failed:". $info['Last_Failed'].
$info['node_name'].$info['schedule_name']."</br>";
}
}
if($info['Last_Missed'] > $info['Last_Completed']){
if ($info['Last_Missed'] > $info['Last_Failed']){
$serverstatus .=" Missed: ". $info['Last_Failed'].
$info['node_name'].$info['schedule_name']."</br>";
}
}
}
$i++;
}
} else {
$serverstatus .= "count is 0";
}
return $serverstatus;
}