Foros del Web » Programando para Internet » PHP »

Problema con un insert

Estas en el tema de Problema con un insert en el foro de PHP en Foros del Web. Amigos al realizar un insert con mi php me arroja este error: You have an error in your SQL syntax; check the manual that corresponds ...
  #1 (permalink)  
Antiguo 30/09/2010, 06:28
 
Fecha de Ingreso: enero-2009
Mensajes: 246
Antigüedad: 15 años, 3 meses
Puntos: 1
Problema con un insert

Amigos al realizar un insert con mi php me arroja este error:

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 ')' at line 1

aqui mi php:

Código PHP:
<?php
$state 
false;
if (
$_POST['action'] == "add") { 
    
$conexion mysql_connect("localhost""usuario""password_db");
    
mysql_select_db("base_de_datos"$conexion);
    
    
$que "INSERT INTO smf_members (memberName, realName, passwd, emailAddress) ";
    
$que.= "VALUES ('".$_POST['memberName']."', '".$_POST['realName']."', '".$_POST['passwd']."', '".$_POST['emailAddress']."',) ";
    
$res mysql_query($que$conexion) or die(mysql_error());
    
$state true;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Insertar datos en MySQL</title>
<style type="text/css">
<!--
body {
    font-family: "Trebuchet MS", Tahoma, Arial;
    font-size: 12px;
    color: #333333;
}
h2 {
    font-size: 16px;
    color: #CC0000;
}
input, select {
    font-family: "Trebuchet MS", Tahoma, Arial;
    font-size: 11px;
    color: #666666;
}
.style4 {font-family: Geneva, Arial, Helvetica, sans-serif; font-size: 12px; font-weight: bold; }
-->
</style>
</head>
<body>
<h2>Ingresar Datos de Usuario </h2>
<form id="insertar" name="insertar" method="post" action="">
  <table width="41%" border="0">
    <tr>
      <td width="20%"><span class="style4">Login:</span></td>
      <td width="3%">&nbsp;</td>
      <td width="77%"><input name="memberName" type="text" id="memberName" size="50" /></td>
    </tr>
    <tr>
      <td class="style4">Nombre Foro:</td>
      <td>&nbsp;</td>
      <td><input name="realName" type="text" id="realName" size="50" /></td>
    </tr>
    <tr>
      <td class="style4">Password:</td>
      <td>&nbsp;</td>
      <td><input name="passwd" type="password" id="passwd" size="50" /></td>
    </tr>
    <tr>
      <td class="style4">Email:</td>
      <td>&nbsp;</td>
      <td><input name="emailAddress" type="text" id="emailAddress" size="50" /></td>
    </tr>
  </table>
  <p>
    <input type="submit" name="Submit" value="Insertar Registro" />
    <input type="hidden" name="action" value="add" />
</p>
</form>
<?php if ($state) { ?>
<p><em>Registro insertado correctamente</em></p>
<?php ?> 
</body>
</html>
Alguien puede decirme cual puede ser mi error.

Salu2
  #2 (permalink)  
Antiguo 30/09/2010, 06:31
Avatar de repara2  
Fecha de Ingreso: septiembre-2010
Ubicación: München
Mensajes: 2.445
Antigüedad: 13 años, 7 meses
Puntos: 331
Respuesta: Problema con un insert

Te sobra la ultima coma

Código PHP:
<?php
$state 
false;
if (
$_POST['action'] == "add") {
    
$conexion mysql_connect("localhost""usuario""password_db");
    
mysql_select_db("base_de_datos"$conexion);

    
$que "INSERT INTO smf_members (memberName, realName, passwd, emailAddress) ";
    
$que.= "VALUES ('".$_POST['memberName']."', '".$_POST['realName']."', '".$_POST['passwd']."', '".$_POST['emailAddress']."') ";
    
$res mysql_query($que$conexion) or die(mysql_error());
    
$state true;
}
?>
1 saludo
  #3 (permalink)  
Antiguo 30/09/2010, 06:46
 
Fecha de Ingreso: enero-2009
Mensajes: 246
Antigüedad: 15 años, 3 meses
Puntos: 1
Respuesta: Problema con un insert

Gracias amigo, solucionado

Etiquetas: insert
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 22:03.