Ver Mensaje Individual
  #1 (permalink)  
Antiguo 04/07/2012, 10:52
lizvy
 
Fecha de Ingreso: julio-2012
Ubicación: valencia
Mensajes: 1
Antigüedad: 11 años, 10 meses
Puntos: 0
Información Fallo de sintaxis sql

Usted tiene un error en la sintaxis SQL, consulte el manual que corresponde a su versión del servidor MySQL para la sintaxis derecho a utilizar cerca de ')' en la línea 1


Hola a todos soy nuevo por este sitio y quisiera un poco de ayuda, porfa.

Este mensaje me sale al hacer un registro a una base de datos desde un formulario, me inserta la imagen a una carpeta especifica peo no me inserta los datos en la base de datos y el código es el siguiente:


<?php require_once('Connections/vtd_bd.php') ; ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}

$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {

//Guardar imagen
if(is_uploaded_file($_FILES['file']['tmp_name'])) { // verifica haya sido cargado el archivo
$ruta= 'images/'.$_FILES['file']['name'];
move_uploaded_file($_FILES['file']['tmp_name'], $ruta);
}

$insertSQL = sprintf("INSERT INTO ac_users (username, password, nombre, apellidos, email, avatar) VALUES (%s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['textfield'], "text"),
GetSQLValueString($_POST['textfield2'], "text"),
GetSQLValueString($_POST['textfield3'], "text"),
GetSQLValueString($_POST['textfield4'], "text"),
GetSQLValueString($_POST['textfield5'], "text"),
GetSQLValueString($_POST['file'], $ruta, "text"));

mysql_select_db($database_vtd_bd, $vtd_bd);
$Result1 = mysql_query($insertSQL, $vtd_bd) or die(mysql_error());

$insertGoTo = "index.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
?>
<!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>Documento sin t&iacute;tulo</title>
</head>

<body>
<form action="<?php echo $editFormAction; ?>" method="POST" enctype="multipart/form-data" name="form1" id="form1">
<table width="600">
<tr>
<td><strong>Nick:</strong></td>
<td>&nbsp;</td>
<td><label>
<input type="text" name="textfield" />
</label></td>
</tr>
<tr>
<td><strong>Contrase&ntilde;a:</strong></td>
<td>&nbsp;</td>
<td><label>
<input type="password" name="textfield2" />
</label></td>
</tr>
<tr>
<td><strong>Nombre:</strong></td>
<td>&nbsp;</td>
<td><label>
<input type="text" name="textfield3" />
</label></td>
</tr>
<tr>
<td><strong>Apellidos:</strong></td>
<td>&nbsp;</td>
<td><label>
<input type="text" name="textfield4" />
</label></td>
</tr>
<tr>
<td><strong>E-mail:</strong></td>
<td>&nbsp;</td>
<td><label>
<input type="text" name="textfield5" />
</label></td>
</tr>
<tr>
<td><strong>Avatar:</strong></td>
<td>&nbsp;</td>
<td><label>
<input type="file" name="file" />
</label></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><label>
<input type="submit" name="Submit" value="Enviar" />
</label></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form1">
</form>
</body>
</html>