Cuando en el php anterior le doy a cualquier registro para modificarlo, en el php de modificar me da el siguiente 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"
El códgigo del segundo script, es el siguiente:
Código PHP:
<?php require_once('Connections/conexion_libros.php'); ?>
<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $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_update"])) && ($_POST["MM_update"] == "form1")) {
$updateSQL = sprintf("UPDATE ps_order_history SET id_employee=%s, id_order=%s, id_order_state=%s, date_add=%s WHERE id_order_history=%s",
GetSQLValueString($_POST['id_employee'], "int"),
GetSQLValueString($_POST['id_order'], "int"),
GetSQLValueString($_POST['id_order_state'], "int"),
GetSQLValueString($_POST['date_add'], "datetime"),
GetSQLValueString($_POST['id_order_history'], "int"));
mysql_select_db($database_conexion_libros, $conexion_libros);
$Result1 = mysql_query($updateSQL, $conexion_libros) or die(mysql_error());
$updateGoTo = "modificar_exitoso.php";
if (isset($_SERVER['QUERY_STRING'])) {
$updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
$updateGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $updateGoTo));
}
mysql_select_db($database_conexion_libros, $conexion_libros);
$valor = $_GET['id_order_history'];
$query_modificar_consulta = "SELECT * FROM ps_order_history where id_order_history=$valor";
$modificar_consulta = mysql_query($query_modificar_consulta, $conexion_libros) or die(mysql_error());
$row_modificar_consulta = mysql_fetch_assoc($modificar_consulta);
$totalRows_modificar_consulta = mysql_num_rows($modificar_consulta);
?><!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ítulo</title>
</head>
<body>
<form method="post" name="form1" action="<?php echo $editFormAction; ?>">
<table align="center">
<tr valign="baseline">
<td nowrap align="right">Id History:</td>
<td><?php echo $row_modificar_consulta['id_order_history']; ?></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Nombre:</td>
<td><input type="text" name="id_employee" value="<?php echo $row_modificar_consulta['id_employee']; ?>" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Autor:</td>
<td><input type="text" name="id_order" value="<?php echo $row_modificar_consulta['id_order']; ?>" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Cantidad:</td>
<td><input type="text" name="id_order_state" value="<?php echo $row_modificar_consulta['id_order_state']; ?>" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Precio:</td>
<td><input type="text" name="date_add" value="<?php echo $row_modificar_consulta['date_add']; ?>" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right"> </td>
<td><input type="submit" value="Actualizar registro"></td>
</tr>
</table>
<input type="hidden" name="MM_update" value="form1">
<input type="hidden" name="id_order_history" value="<?php echo $row_modificar_consulta['id_order_history']; ?>">
</form>
<p> </p>
</body>
</html>
<?php
mysql_free_result($modificar_consulta);
?>
Y nada, que no doy con el error, a ver si alguien me puede echar un cable.
Mil gracias :)