Ver Mensaje Individual
  #1 (permalink)  
Antiguo 28/10/2012, 21:40
keine_lust
 
Fecha de Ingreso: octubre-2012
Mensajes: 35
Antigüedad: 11 años, 5 meses
Puntos: 0
problema al cargar tabla.

buenas noches.
cuando intento cargar una tabla me da error.
no se cual es el problema.
ingreso en el navegador localhost/appweb1.
y no me carga la tabla me dice que tengo un error que es el siguiente:

Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\appweb1\clases\usuarios.php on line 19.

este el el codigo de la clase usuarios.php:

<?php
class usuarios extends basedatos
{
private $id;
private $nombre;
private $direccion;
private $telefono;
private $correo;
private $fechanac;

private $query;
private $resul;

public function consultarUsuarios()
{
$this->query = "SELECT * FROM usuarios";
$this->resul = mysql_query($this->query, $this->conx);

while ($row = mysql_fetch_array($this->resul)) //esta es la linea 19 donde dice que me aparece el error
{
echo "<tr>";
echo "<td>".$row['id'] ."</td>";
echo "<td>".$row['nombre'] ."</td>";
echo "<td>".$row['direccion']."</td>";
echo "<td>".$row['telefono'] ."</td>";
echo "<td>".$row['correo'] ."</td>";
echo "<td>".$row['fechanac'] ."</td>";
echo "<td><select name='acc' class='acc'>";
echo "<option value=''>Seleccione...</option>";
echo "<option value='consultar.php?id=".$row['id']."'>Consultar</option>";
echo "<option value='modificar.php?id=".$row['id']."'>Modificar</option>";
echo "<option value='eliminar.php?id=".$row['id']."'>Eliminar</option>";
echo "</select></td>";
echo "</tr>";
}
}

public function consultarUsuario($id)
{
$this->query = "SELECT * FROM usuarios WHERE id = $id";
$this->resul = mysql_query($this->query, $this->conx);

while ($row = mysql_fetch_array($this->resul))
{

echo "<tr>";
echo "<th colspan='2'>DATOS DEL USUARIO</th>";
echo "</tr>";

echo "<tr>";
echo "<td><strong>Identificador:</strong></td>";
echo "<td>".$row['id']."</td>";
echo "</tr>";

echo "<tr>";
echo "<td><strong>Nombre Completo:</strong></td>";
echo "<td>".$row['nombre']."</td>";
echo "</tr>";

echo "<tr>";
echo "<td><strong>Dirección:</strong></td>";
echo "<td>".$row['direccion']."</td>";
echo "</tr>";

echo "<tr>";
echo "<td><strong>Teléfono:</strong></td>";
echo "<td>".$row['telefono']."</td>";
echo "</tr>";

echo "<tr>";
echo "<td><strong>Correo Electrónico:</strong></td>";
echo "<td>".$row['correo']."</td>";
echo "</tr>";

echo "<tr>";
echo "<td><strong>Fecha Nacimiento:</strong></td>";
echo "<td>".$row['fechanac']."</td>";
echo "</tr>";
}
}

public function insertarUsuario($nombre, $direccion, $telefono, $correo, $fechanac)
{
$this->nombre = $nombre;
$this->direccion = $direccion;
$this->telefono = $telefono;
$this->correo = $correo;
$this->fechanac = $fechanac;

$this->query = "INSERT INTO usuarios VALUES(default, '$this->nombre',
'$this->direccion', $this->telefono, '$this->correo', '$this->fechanac')";

if (mysql_query($this->query))
{
echo "<script type='text/javascript'>";
echo "alert('Usuario Adicionado con Exito');";
echo "window.location.replace('index.php');";
echo "</script>";
}
else
{
echo "Error: ".mysql_error();
}

}

public function modificarUsuario($id, $nombre, $direccion, $telefono, $correo, $fechanac)
{
$this->nombre = $nombre;
$this->direccion = $direccion;
$this->telefono = $telefono;
$this->correo = $correo;
$this->fechanac = $fechanac;

$this->query = "UPDATE usuarios SET nombre = '$this->nombre',
direccion = '$this->direccion', telefono = $this->telefono,
correo = '$this->correo', fechanac = '$this->fechanac'
WHERE id = $id";

if (mysql_query($this->query))
{
echo "<script type='text/javascript'>";
echo "alert('Usuario Modificado con Exito');";
echo "window.location.replace('index.php');";
echo "</script>";
}
else
{
echo "Error: ".mysql_error();
}

}

public function eliminarUsuario($id)
{
$this->query = "DELETE FROM usuarios WHERE id = $id";

if (mysql_query($this->query))
{
echo "<script type='text/javascript'>";
echo "alert('Usuario Eliminado con Exito');";
echo "window.location.replace('index.php');";
echo "</script>";
}
else
{
echo "Error: ".mysql_error();
}
}

public function cargarUsuario($id)
{
$this->query = "SELECT * FROM usuarios WHERE id = $id";
$this->resul = mysql_query($this->query, $this->conx);

while ($row = mysql_fetch_array($this->resul))
{
echo "<tr>
<th colspan='2'>MODIFICAR USUARIO</th>
</tr>
<tr>
<td><strong>Nombre:</strong></td>
<td><input type='text' name='nombre' value='".$row['nombre']."'/></td>
</tr>
<tr>
<td><strong>Dirección:</strong></td>
<td><input type='text' name='direccion' value='".$row['direccion']."'/></td>
</tr>
<tr>
<td><strong>Teléfono:</strong></td>
<td><input type='text' name='telefono' value='".$row['telefono']."'/></td>
</tr>
<tr>
<td><strong>Correo Electrónico:</strong></td>
<td><input type='text' name='correo' value='".$row['correo']."'/></td>
</tr>
<tr>
<input type='hidden' name='id' value='".$row['id']."'/>
<td><strong>Fecha de Nacimiento:</strong></td>
<td><input type='text' name='fechanac' id='fechanac' value='".$row['fechanac']."'/></td>
</tr>
<tr>
<td colspan='2'><input type='submit' value='Modificar' /></td>
</tr> ";
}
}

}
?>

por favor ayúdenme. gracias