php - Array to string conversion smarty template -
hello have array string conversion erro code:
index.php:
code:
$hoarr = array(1,2,3); foreach ($hoarr $hid) { $mysqli = mysqli_connect("localhost", "root", "", "zabbixtest"); if (!$mysqli) { die("connection failed: " . mysqli_connect_error()); } $sql = "select errors_from hosts hostid = '$hid'"; $re = mysqli_query($mysqli, $sql); while ($row = mysqli_fetch_assoc($re)) { $query_times[] = $row['errors_from']; } mysqli_free_result($re); mysqli_close($mysqli); } $smarty->assign('query_times',$query_times); and index.tpl:
code:
<p>{$query_times}</p> i have no idea whats wrong it..
you try assign array $smarty->assign can assign string.
use instead:
$query_string = implode ( "," , $query_times ); $smarty->assign('query_times',$query_string);
Comments
Post a Comment