Ver Mensaje Individual
  #4 (permalink)  
Antiguo 17/08/2012, 16:03
ameno123
 
Fecha de Ingreso: julio-2010
Mensajes: 158
Antigüedad: 14 años, 7 meses
Puntos: 1
De acuerdo Respuesta: Error PHP con MYSQL

Código PHP:
Ver original
  1. <?php
  2.  
  3. include("config.php");
  4.  
  5. // connect to the mysql server
  6. $link = mysql_connect($server, $db_user, $db_pass)
  7. or die ("Could not connect to mysql because ".mysql_error());
  8.  
  9. // select the database
  10. mysql_select_db($database)
  11. or die ("Could not select database because ".mysql_error());
  12.  
  13. // check if the username is taken
  14. $check = "select id from $table where username = '".$_POST['username']."';";
  15. $qry = mysql_query($check)
  16. or die ("Could not match data because ".mysql_error());
  17. $num_rows = mysql_num_rows($qry);
  18. if (empty($_POST['username'])) {
  19. die ("<META HTTP-EQUIV='Refresh' CONTENT='0; URL=register1.php?error=7'>");
  20. }
  21.  
  22.  
  23.  
  24. if ($num_rows != 0) {
  25. die ("<META HTTP-EQUIV='Refresh' CONTENT='0; URL=register1.php?error=1'>");
  26. } else {
  27.  
  28. // insert the data
  29. $insert = mysql_query("insert into $table values (NULL, '".$_POST['username']."', '".$password2."', '', '0', '".$_POST['name1']."', '".$_POST['email']."', 'images/avatar.jpg', '&nbsp;', '0')")
  30. or die("Could not insert data because ".mysql_error());
  31.  
  32. // print a success message
  33. echo "Has sido registrado!<br>";
  34. echo "Ahora puedes <a href=login1.php>loguear</a>";
  35. }
  36.  
  37. ?>

Los espacios que guarda que no tienen nada están porque la bd esta conectada con un juego.