Ver Mensaje Individual
  #1 (permalink)  
Antiguo 11/03/2010, 17:36
dpbataller
 
Fecha de Ingreso: agosto-2009
Mensajes: 134
Antigüedad: 14 años, 8 meses
Puntos: 3
Error al mostrar imagen de perfil de usuario

Hola, estoy acabando mi pequeño proyecto y tengo un gran problema.
Mi intención es que tras el logueo del usario , se cargue su foto de perfil previamente almacenada en la bd. Pero me sale este error...

Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\proyecto\index.php on line 41



Éste es el código


Código PHP:
Ver original
  1. <?php
  2.  
  3.  $usuario = $_POST['user'];
  4.  
  5. ?>
  6. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  7. <html xmlns="http://www.w3.org/1999/xhtml">
  8. <head>
  9. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  10. <link rel="stylesheet" href="css/indexBlog.css" type="text/css" media="screen">
  11. <title>Blog | Mi blog personal</title>
  12. </head>
  13.  
  14. <body>
  15.             <div id="pagina">
  16.            
  17.                         <div class="topmenu">
  18.                                 <ul>
  19.                                     <li > <a title="Blog Iaig" href="index.php"> Inicio </a> </li>
  20.                                     <li> | </li>
  21.                                     <li > <a title="Blog Iaig" href="crearEntrada.php"> Crear Entrada </a> </li>
  22.                                     <li> | </li>
  23.                                     <li > <a title="Blog Iaig" href="usuarios.php"> Usuarios </a> </li>
  24.                                     <li> | </li>
  25.                                     <li > <a title="Blog Iaig" href="cerrarSesion.php"> Salir </a> </li>
  26.                                  
  27.                                 </ul>
  28.                                 <?php
  29.                                     echo "<h3 style='float:right;'><b>Bienvenido/a: <u><i>".$_SESSION['usuario']."</u></i></b></h3>";
  30.                                 ?>
  31.                         </div>
  32.                         <div id="header">
  33.                             <img src="imagenes/logo.png" width="250" height="82" alt="Blog" / id="logo">
  34.                            
  35.                              <?php
  36.                                               $usuario = $_POST['user'];
  37.                                               $conexion=mysql_connect("localhost","root","pedrosa") or die ("Error al conectar con la BD");
  38.                                               $db=mysql_select_db("blog",$conexion) or die ("Error al conectar con tu Base de datos");
  39.                                               $q = mysql_query("SELECT id_usuario,nombre,contra,imagen FROM usuarios where nombre = $usuario");  
  40.                                                 while($res = mysql_fetch_array($q)){    
  41.                                                
  42.                                                        
  43.                                                     echo "<div id='imgUserheader'>";
  44.                                                             echo "<img src='".$res['imagen']."'>";
  45.                                                     echo "</div>";
  46.                                              }
  47.                                              
  48.                            
  49.                                
  50.                             ?>
  51.  
  52.                         </div>