سؤال

i'm having a problem with my php code: browser show me this error: ERRNO: 8|TEXT:Undefined index:N° Asset con guasti i'm trying to do dinamic table taking data from a database, but something with the 'fetch_array(MYSQLI_ASSOC)' function must have gone wrong

<?php 
require_once('FirePHPCore/FirePHP.class.php');
require_once('error_handler.php');
require_once('config.php');
$firephp = FirePHP::getInstance(true);

$mysqli = new mysqli(DB_HOST, 'Elia', '1234', 'test');

//query SQL da eseguire
$query = 'SELECT * FROM `livello_di_servizio`';     

//esegue la query
$result = $mysqli->query($query);
.
.
.
.
.
.
while ($row = $result->fetch_array(MYSQLI_ASSOC)){
//errore (undefined index)
echo "<tr><td class='tab_sx' style='text-align: left'>".$row['Etichette di riga']."</td>";
echo "<td class='gruppo' style='text-align: center'>".$row['Numero Macchine']."</td>";
echo "<td class='gruppo' style='text-align: right'>".$row['Ore Pianificate Mese']."</td>";
echo "<td class='gruppo' style='text-align: center'>".$row['N° Asset con guasti']."</td>";
echo "<td class='gruppo' style='text-align: right'>".$row['DT Periodo']."</td>";
echo "<td class='tab_guasti_top' style='text-align: center'>".$row['N° Guasti Totali']."</td>";
echo "<td bgcolor='#FFF' class='tab_dx' style='text-align: right'>".$row['QT \(Indisponibilità\)']."</td></tr>";
}
echo "</table></div></div>";?>
هل كانت مفيدة؟

المحلول

hm. might be a problem with encoding : try to add this after the $mysqli = new mysqli(DB_HOST, 'Elia', '1234', 'test'); :

$mysqli->set_charset("utf8")

if it doesn't work, juste don't use space or special char (like °) in your row name, it's a very poor practice.

and also, please print out the $row array :

print_r($row);
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top