Ver Mensaje Individual
  #1 (permalink)  
Antiguo 06/05/2013, 04:18
edie8
 
Fecha de Ingreso: noviembre-2011
Mensajes: 516
Antigüedad: 12 años, 5 meses
Puntos: 10
Error en php nose como solucionar

Buenas
tengo un problema con un codigo php que me da un error en el archivo insertar.php nose que tengo mal esto son el error y el codigo:
Código error:
Ver original
  1. Warning: mysql_query() expects parameter 2 to be resource, string given in /home/u437222420/public_html/insertar.php on line 39 Warning: mysql_fetch_array() expects parameter 1 to be resource, null given in /home/u437222420/public_html/insertar.php on line 40
y el codigo:
Código PHP:
Ver original
  1. <?php session_start(); ?>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  3. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  4. <html xmlns="http://www.w3.org/1999/xhtml">
  5. <head>
  6. <title>Polling Ajax/Php :: insertar registros</title>
  7. <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  8. <style type="text/css">
  9. /*<![CDATA[*/
  10. body{font-size: 10pt;font-family: verdana, sans-serif;color: #332B22;}
  11. .texto{width: 180px;}
  12. label{display: inline-block; width: 100px;}
  13. .procesar{background-color:#552922; margin: 10px 0; color: #FFFFFF; width: 185px;}
  14. .procesar:hover{background-color:#8E2E04; cursor: pointer;}
  15. h1{font-size: 14pt; font-weight: bold;}
  16. /*]]>*/
  17. </style>
  18. </head>
  19. <body>
  20. <h1>Polling Ajax/Php :: insertar registros</h1>
  21. <div>
  22. <form action="<?php $_SERVER['SCRIPT_NAME']; ?>" method="post">
  23. <input type="hidden" value="1" name="insertar" />
  24. <input type="hidden" value="2" name="nombre" id="nombre" class="texto" /><br />
  25. <label for="mensaje">mensaje</label><input type="text" value="" name="mensaje" id="mensaje" class="texto" /><br />
  26. <label><!-- fix --></label><input type="submit" name="procesar" value="Insertar nuevo registro" class="procesar" />
  27. </form>
  28. </div>
  29. <?php
  30. if(isset($_POST['insertar'])){
  31. include('conectar.php');
  32. $nombre = str_replace('|',' ', $_POST['nombre']);
  33. $mensaje = str_replace('|',' ', $_POST['mensaje']);
  34. $consulta = "INSERT INTO polling_demo (nombre, mensaje) VALUES ('$nombre', '$mensaje')";
  35. $req = mysql_query($consulta);
  36. $consulta = "SELECT * FROM polling_demo ORDER BY id_polling DESC";
  37. $req = mysql_query($consulta);
  38. $res = mysql_num_rows($req);
  39. $prueb=mysql_query("select * from usuarios where id='$nombre'",$consulta);
  40. while($pr=mysql_fetch_array($prueb))
  41. {$es=$pr['usuarios'];}
  42. file_put_contents('control_cambios.txt', "$es|$nombre|$mensaje|" . $_SESSION['reg_actuales'], LOCK_EX);
  43. }else{
  44. }
  45. ?>
  46. </body>
  47. </html>
trato de remediarlo pero nose porque no me deja acer ese while le necesito para sacar el nombre del usuario que mete el comentario para la notificacion un saludo.