Ver Mensaje Individual
  #2 (permalink)  
Antiguo 05/03/2012, 00:30
Avatar de repara2
repara2
 
Fecha de Ingreso: septiembre-2010
Ubicación: München
Mensajes: 2.445
Antigüedad: 14 años, 6 meses
Puntos: 331
Respuesta: error php con base de datos

Además de un par de error de sintaxis, el if está mal escrito, ahí va:

Código PHP:
Ver original
  1. <?php
  2.  
  3. ini_set("display_errors", 1);
  4.  
  5. mysql_connect("localhost", "pag", "87215851" ) or die(mysql_error());
  6.  
  7. function quitar($mensaje)
  8. {
  9.     $mensaje = str_replace("<","<",$mensaje);
  10.     $mensaje = str_replace(">",">",$mensaje);
  11.     $mensaje = str_replace("'","'",$mensaje);
  12.     $mensaje = str_replace("\\","",$mensaje);
  13.     return $mensaje;
  14. }
  15.  
  16. if(trim($_POST["nick"]) != "")
  17. {
  18.  
  19.     $nick = quitar($_POST["nick"]);
  20.  
  21.     $result = mysql_query("SELECT * FROM usuarios WHERE nick='$nick'");
  22.     if($row = mysql_fetch_array($result))
  23.     {
  24.         if($row["nick"] == $nick) //El usuario existe
  25.         {
  26.             //90 dias dura la cookie
  27.  
  28.             setcookie("usNick",$nick,time()+7776000);
  29.             echo header ("Location: http://www.pag.com/reg.php");
  30.         }//if($row["nick"] == $nick) //El usuario existe
  31.         else //El usuario no existe
  32.         {
  33.             echo header ("Location: http://www.pagerror.com");
  34.         }
  35.     }//if($row = mysql_fetch_array($result))
  36.  
  37. }//if(trim($_POST["nick"]) != "")
  38. ?>
__________________
Fere libenter homines, id quod volunt, credunt.