Ver Mensaje Individual
  #2 (permalink)  
Antiguo 11/04/2007, 08:46
Avatar de GatorV
GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 18 años
Puntos: 2135
Re: Error en busquedad ODBC

Código PHP:
<html>
<head>
<title>Ejemplo de PHP</title>
</head>
<body>
<TABLE>
<TR>
<TD><b>CONSULTA DATOS DE PRUEBA :</b></TD>
</TR>
</TABLE>
<hr>
<?php


include("conex.phtml");
$odbc_conn=Conectarse();
$sql="select * from tabla where codprue=6200 and resprue=3200 "//

**** este registro no existe ******
**** 
pasa directo al else muestra el encabezado pero no muestra nada porque no hay nada *****
**** 
se supone que deberia mostrarme el error ****

if (!
$rs_odbc=odbc_exec($odbc_conn$sql))
{
echo 
"Query error! ODBC error: "odbc_errormsg();
}
else
{

if( 
odbc_num_rows$rs ) > ) {

?>

<TABLE BORDER=1 CELLSPACING=1 CELLPADDING=1>
<TR><TD>&nbsp;<B>Carrera</B></TD> <TD>&nbsp;<B>Resolucion</B>&nbsp;</TD><TD>&nbsp;<B>Nombre Carrera </B>&nbsp;</TD><TD>&nbsp;<B>Año Acad.</B>&nbsp;</TD><TD>&nbsp;<B>Fecha Proc.</B>&nbsp;</TD><TD>&nbsp;<B>Año-Mes Proc.</B>&nbsp;</TD></TR>

<?php
while($row_odbc odbc_fetch_array($rs_odbc))
{
printf("<tr><td>&nbsp;%s</td><td>&nbsp;%s&nbsp;</td><td>&nbsp;%s&nbsp;</td><td>&nbsp;%s&nbsp;</td><td>&nbsp;%s&nbsp;</td><td>&nbsp;%s&nbsp;</td></tr>"$row_odbc["codprue"],$row_odbc["resprue"],$row_odbc["nombprue"],$row_odbc["anoprue"],$row_odbc["fecprue"],$row_odbc["fecprue"]);
}
} else {

    echo 
"Error no existe registro";
}
}
odbc_free_result($rs_odbc);
odbc_close($odbc_conn);
?>
</table>
</body>
</html>