
Originariamente inviata da
lucavizzi
mysql_query('tua query') restituisce False
Quale query stai usando?
Codice PHP:
$query = "SELECT ...";
$result = mysql_query($query);
if (!$result) {
die("Errore nella query $query: " . mysql_error());
}
if(mysql_num_rows($result) != 1) {
die("l'ID passato via GET è errato");
}
list(
$project_name,...) = mysql_fetch_row($result);
$conn=mysql_connect('localhost','root','');
$db=mysql_select_db('excel',$conn);
$filename = "prova.xls"; // File Name
// Download file
header("Content-Disposition: attachment; filename=\"$filename\"");
header("Content-Type: application/vnd.ms-excel");
$result = mysql_query('select name,work from info');
// Write data to file
$flag = false;
while ($row = mysql_fetch_assoc($result)) {
if (!$flag) {
// display field/column names as first row
echo implode("\t", array_keys($row)) . "\r\n";
$flag = true;
}
echo implode("\t", array_values($row)) . "\r\n";
}
Devo usare $query?