Ver Mensaje Individual
  #1 (permalink)  
Antiguo 03/10/2013, 06:28
Charlie1
 
Fecha de Ingreso: octubre-2013
Mensajes: 30
Antigüedad: 10 años, 7 meses
Puntos: 3
Pregunta Sistema de registro en PHP.

Llevo unos cuantos días intentando hacer un sistema de registros php y mysql para mi web pero me encuentro con el siguiente error:
Cita:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-mail, password, rpassword) VALUES ('usuario', '[email protected]', 'contraseña' at line 1
Me indica que el fallo está en la linea 1 de este código:


Código PHP:
Ver original
  1. <?php require_once('Connections/ConexionP.php'); ?>
  2. <?php
  3. if (!function_exists("GetSQLValueString")) {
  4. function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
  5. {
  6.   if (PHP_VERSION < 6) {
  7.     $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  8.   }
  9.  
  10.   $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
  11.  
  12.   switch ($theType) {
  13.     case "text":
  14.       $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  15.       break;    
  16.     case "long":
  17.     case "int":
  18.       $theValue = ($theValue != "") ? intval($theValue) : "NULL";
  19.       break;
  20.     case "double":
  21.       $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
  22.       break;
  23.     case "date":
  24.       $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  25.       break;
  26.     case "defined":
  27.       $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
  28.       break;
  29.   }
  30.   return $theValue;
  31. }
  32. }
  33.  
  34. $editFormAction = $_SERVER['PHP_SELF'];
  35. if (isset($_SERVER['QUERY_STRING'])) {
  36.   $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
  37. }
  38.  
  39. if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
  40.   $insertSQL = sprintf("INSERT INTO registro (nombre, e-mail, password, rpassword) VALUES (%s, %s, %s, %s)",
  41.                        GetSQLValueString($_POST['nombre'], "text"),
  42.                        GetSQLValueString($_POST['email'], "text"),
  43.                        GetSQLValueString($_POST['password'], "text"),
  44.                        GetSQLValueString($_POST['rpassword'], "text"));
  45.  
  46.   mysql_select_db($database_ConexionP, $ConexionP);
  47.   $Result1 = mysql_query($insertSQL, $ConexionP) or die(mysql_error());
  48.  
  49.   $insertGoTo = "registro.php";
  50.   if (isset($_SERVER['QUERY_STRING'])) {
  51.     $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
  52.     $insertGoTo .= $_SERVER['QUERY_STRING'];
  53.   }
  54.   header(sprintf("Location: %s", $insertGoTo));
  55. }
  56. ?>
  57. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  58. <html xmlns="http://www.w3.org/1999/xhtml">
  59. <head>
  60. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  61. <title>Documento sin título</title>
  62. </head>
  63.  
  64. <body>
  65. <form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1">
  66.   <table align="center">
  67.     <tr valign="baseline">
  68.       <td nowrap="nowrap" align="right">*Nombre:</td>
  69.       <td><input type="text" name="nombre" value="" size="32" required="required" /></td>
  70.     </tr>
  71.     <tr valign="baseline">
  72.       <td nowrap="nowrap" align="right">*E-mail:</td>
  73.       <td><input type="email" name="email" value="" size="32" required="required" /></td>
  74.     </tr>
  75.     <tr valign="baseline">
  76.       <td nowrap="nowrap" align="right">*Contraseña:</td>
  77.       <td><input type="password" name="password" value="" size="32" required="required" /></td>
  78.     </tr>
  79.     <tr valign="baseline">
  80.       <td nowrap="nowrap" align="right">*Repetir Contraseña:</td>
  81.       <td><input type="password" name="rpassword" value="" size="32" required="required" /></td>
  82.     </tr>
  83.     <tr valign="baseline">
  84.       <td nowrap="nowrap" align="right">&nbsp;</td>
  85.       <td><input type="submit" value="Registrarse" /></td>
  86.     </tr>
  87.   </table>
  88.   <input type="hidden" name="MM_insert" value="form1" />
  89. </form>
  90. <p>&nbsp;</p>
  91. </body>
  92. </html>

Pero no veo el error, aunque dice que es un error de sintaxis yo no veo nada mal, también me comentaron que las nuevas versiones de los servidores están lanzando errores como este, pero la verdad no sé como abarcarlo y agradecería vuetra ayuda os dejo también el codigo del archivo 'Connections/ConexionP.php'
aunque no creo que tenga nada que ver:

Código PHP:
Ver original
  1. <?php
  2. # FileName="Connection_php_mysql.htm"
  3. # Type="MYSQL"
  4. # HTTP="true"
  5. $hostname_ConexionP = "localhost";
  6. $database_ConexionP = "web";
  7. $username_ConexionP = "root";
  8. $password_ConexionP = "1234";
  9. $ConexionP = mysql_pconnect($hostname_ConexionP, $username_ConexionP, $password_ConexionP) or trigger_error(mysql_error(),E_USER_ERROR);
  10. ?>