Ver Mensaje Individual
  #1 (permalink)  
Antiguo 26/09/2006, 13:10
Freak17
 
Fecha de Ingreso: abril-2006
Mensajes: 140
Antigüedad: 18 años, 1 mes
Puntos: 0
ayuda con reporte php en excel

hola amigos de fdw.

este es el codigo ke tengo para ke los datos encontrados en una BD mysql me los guarde en una hoja de excel.

Código PHP:

<?php
header
("Content-type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename=reporte.xls");
//en la sigte linea colocar entre comillas el nombre del servidor mysql (generalmente, localhost)
$servidor="localhost";
//en la sigte linea colocar entre comillas el nombre de usuario
$user="root";
//en la sigte linea colocar entre comillas la contraseña
$pass="123";
//en la sigte linea colocar entre comillas el nombre de la base de datos
$db="prueba";
mysql_connect($servidor,$user,$pass);
mysql_select_db($db);
$qry=mysql_query("select * from datos ".$_GET['tabla']);
$campos mysql_num_fields($qry);
$i=0;
echo 
"<table><tr>";
while(
$i<$campos){
echo 
"<td>"mysql_field_name ($qry$i);
echo 
"</td>";
$i++;
}
echo 
"</tr>";
while(
$row=mysql_fetch_array($qry)){
echo 
"<tr>";
for(
$j=0$j<$campos$j++) {
echo 
"<td>".$row[$j]."</td>";
}
echo 
"</tr>";
}
echo 
"</table>";
?>
el problema lo tengo que al ejecutar la pagina, me genera el siguiente error:

Warning: Cannot modify header information - headers already sent by (output started at C:\AppServ\www\Reporte\reporte.php:8) in C:\AppServ\www\Reporte\reporte.php on line 9

Warning: Cannot modify header information - headers already sent by (output started at C:\AppServ\www\Reporte\reporte.php:8) in C:\AppServ\www\Reporte\reporte.php on line 10

esas lineas corresponden a :
9) header("Content-type: application/vnd.ms-excel");
10)header("Content-Disposition: attachment; filename=reporte.xls");
lo ke kiero saber, cual es el problema porke debido a ke aun soy novato no conosco el error y las posibles soluciones. porfavor ayuda!

este codigo esta corriendo bajo :
# Apache Web Server Version 2.2.2
# PHP Script Language Version 5.1.4
# MySQL Database Version 5.0.22
# phpMyAdmin Database Manager Version 2.8.2

de antemano gracias