Ver Mensaje Individual
  #1 (permalink)  
Antiguo 11/02/2012, 00:49
danielmeza
 
Fecha de Ingreso: febrero-2012
Mensajes: 24
Antigüedad: 12 años, 2 meses
Puntos: 0
Problema Reporte

Buenas noches,

estoy intentando exportar de una base de datos a un EXCELL con este codigo

Código PHP:
<?php
//Exportar datos de php a Excel
header("Content-Type: application/vnd.ms-excel");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("content-disposition: attachment;filename=Reportes.xls");
?>
<HTML LANG="es">
<TITLE>::. Exportacion de Datos .::</TITLE>
</head>
<body>
<?php
$NombreBD 
"Prueba";
$Servidor "localhost";
$Usuario "Prueba";
$Password ="";
$IdConexion mysql_connect($Servidor$Usuario$Password);
mysql_select_db($NombreBD$IdConexion);

$sql "SELECT C001PATEN, C001ADUSEC, C001REFPED, C001NUMPED, C001TIPOPE, D001FECEXT, D001FECREM, C001ADUSE, D001FECCAM, F001VALSEG FROM AT001 Where 2000003";
$result=mysql_query($sql,$IdConexion);

?>

<TABLE BORDER=1 align="center" CELLPADDING=1 CELLSPACING=1>
<TR>
<TD>PATENTE</TD>
<TD>ADUANA</TD>
<TD>REFERENCIA</TD>
<TD>PEDIMENTO</TD>
<TD>TIPO OPERACION</TD>
<TD>FECHA 1</TD>
<TD>FECHA 2</TD>
<TD>ADUSE</TD>
<TD>FECHA 3</TD>
<TD>VALOR</TD>
</TR>
<?php
while($row mysql_fetch_array($result)) {
printf("
"
.$row["C001PATEN"]."
"
.$row["C001ADUSEC"]."
"
.$row["C001REFPED"]."
"
.$row["C001NUMPED"]."
"
.$row["C001TIPOPE"]."
"
.$row["D001FECEXT"]."
"
.$row["D001FECREM"]."
"
.$row["C001ADUSE"]."
"
.$row["D001FECCAM"]."
"
.$row["F001VALSEG"]."
"
);
}
mysql_free_result($result);
mysql_close($IdConexion); //Cierras la Conexión
?>
</table>
</body>
</html>
al ejecutarlo me descarga el EXCELL
y viene estos errores

Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /opt/lampp/htdocs/otra.php on line 39
Warning: mysql_free_result() expects parameter 1 to be resource, boolean given in /opt/lampp/htdocs/otra.php on line 53

que sera? Gracias.