Ciao a tutti, ho provato a fare delle ricerche ma non ho trovato soluzioni....devo esportare una tabella da mysql a exel in php ed ho usato questo codice:

<?php
mysql_connect(localhost, "root");
mysql_select_db("db");
$query="SELECT codice, nome, prezzo FROM prodotti";
$prova = mysql_query($query);
$row_prova = mysql_fetch_assoc($prova );

do
{
$righe.= "\"".$row_prova ['codice']."\"\t\"".$row_prova ['nome']."\"\t\"".$row_prova ['prezzo']."\"\n";
}
while ($row_prova = mysql_fetch_assoc($prova ));

header("Content-type: application/vnd.ms-excel"); //vitale!!
header("Content-disposition: prova.xls");
header("Pragma: no-cache");
header("Expires: 0");

print $righe;
exit;
?>

mi da questo errore:

Warning: Cannot modify header information - headers already sent by (output started at C:\wamp2\www\gemacchine\prova.php:3) in C:\wamp2\wwwprova.php on line 16

Warning: Cannot modify header information - headers already sent by (output started at C:\wamp2\www\gemacchine\prova.php:3) in C:\wamp2\www\prova.php on line 17

Warning: Cannot modify header information - headers already sent by (output started at C:\wamp2\www\gemacchine\prova.php:3) in C:\wamp2\www\prova.php on line 18

Warning: Cannot modify header information - headers already sent by (output started at C:\wamp2\www\gemacchine\prova.php:3) in C:\wamp2\www\prova.php on line 19


dove sbaglio?
Scusate la mia ignoranza...Grazie