I keep getting an array to string conversion notice, it seems to be from the way I have escaped (or haven’t escaped) the MySQL statement. If I do not use a PHP variable and put the data in as text it works, but with the variables it shows an error. Help! 🙂
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;
}
You forgot the
ASkeyword:should be
Therefore
$info['Last_Failed']had no associative index, etc.Per your comment, it appears
$nodewas an array after all, and you need to replace this:with this: