Foros del Web » Programando para Internet » PHP »

error en consulta

Estas en el tema de error en consulta en el foro de PHP en Foros del Web. amigos tengo un problema para generar una consulta tengo una pagina donde seleccion un combo para realizar una consulta y en un caudro de texto ...
  #1 (permalink)  
Antiguo 14/07/2008, 10:54
 
Fecha de Ingreso: septiembre-2007
Mensajes: 47
Antigüedad: 16 años, 6 meses
Puntos: 0
error en consulta

amigos

tengo un problema para generar una consulta
tengo una pagina donde seleccion un combo para realizar una consulta y en un caudro de texto digito lo que voy a buscar, cuando envio el formulario para que me haga la consulta me sale este error

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:Archivos de programaxampphtdocsSICEconsultamultiple.php on line 38
El registro no existe

ESTE ES EL CODIGO DE LA CONSULTA


<html>

<head>
<title></title>
<style>
<!--.blur {filter: blur (add = 8, direction = 245, strenght = 24); height: 40} -->
</style>
</head>

<body bgcolor = "#019833">
<center><font size = "5" color = "blue" face = "arial black" class = "blur">
<?php
include ("conexion.php");
$opc = $cbocampo;
switch($opc)
{
case 1:
$consulta = "select * from datos where identificador = '$txtvalor'";
break;
case 2:
$consulta = "select * from datos where nombre like '%$txtvalor%'";
break;
case 3:
$consulta = "select * from datos where telefonocasa = '$txtvalor'";
break;
case 4:
$consulta = "select * from datos where telefonoof = '$txtvalor'";
break;
case 5:
$consulta = "select * from datos where email like '%$txtvalor%'";
break;
case 6:
$consulta = "select * from datos where direccion like '$txtvalor'";
break;
}
$resultado = mysql_query($consulta);
$numreg = mysql_num_rows($resultado);
if ($numreg == 0)
{
echo "El registro no existe";
}
else
{
?>
</font></center>
<font size = "2" color = "white" face = "arial black">
<table border = "1" align="center" bordercolor = "blue">
<tr>
<th><font face = "arial black"> Identificador </font></th>
<th><font face = "arial black"> Nombre </font></th>
<th><font face = "arial black"> Telefono casa </font></th>
<th><font face = "arial black"> Telefono oficina </font></th>
<th><font face = "arial black"> E-mail </font></th>
<th><font face = "arial black"> Dirección </font></th>
<?
while($filas = mysql_fetch_array($resultado))
{
?>
<tr>
<td><font color = "white" face = "arial black"><? echo $filas["identificador"]; ?></font></td>
<td><font color = "white" face = "arial black"><? echo $filas ["nombre"]; ?></font></td>
<td><font color = "white" face = "arial black"><? echo $filas ["telefonocasa"]; ?></font></td>
<td><font color = "white" face = "arial black"><? echo $filas ["telefonoof"] ?> </font></td>
<td><font color = "white" face = "arial black"><? echo $filas ["email"] ?> </font></td>
<td><font color = "white" face = "arial black"><? echo $filas ["direccion"]; ?></font></td>
</tr>
<?
} //mq
} //else
?>
</table>
</font>
</body>
</html>
  #2 (permalink)  
Antiguo 14/07/2008, 12:36
Avatar de cala932  
Fecha de Ingreso: septiembre-2006
Ubicación: San Juan-Argentina
Mensajes: 902
Antigüedad: 17 años, 6 meses
Puntos: 9
Respuesta: error en consulta

Hola, proba reemplazando esto:
Código PHP:
$numreg mysql_num_rows($resultado); 
//POR ESTO
$numreg mysql_affected_rows($resultado); 
Saludos
__________________
->Aprender es un proceso que incluye el error..
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 02:09.