Foros del Web » Programando para Internet » PHP »

ayuda con error

Estas en el tema de ayuda con error en el foro de PHP en Foros del Web. hola saludos a todos, la pagina esta bien buena, pero nesesito ayuda, al momento de enviar el formulario para enviarlo a un pdf en php ...
  #1 (permalink)  
Antiguo 01/09/2008, 11:06
 
Fecha de Ingreso: septiembre-2008
Mensajes: 58
Antigüedad: 15 años, 7 meses
Puntos: 0
ayuda con error

hola saludos a todos, la pagina esta bien buena,

pero nesesito ayuda,

al momento de enviar el formulario para enviarlo a un pdf en php

me marca esto

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 '±o) VALUES (NULL, '1', '1', '11', '1', '1', '11', '1', '1', '1', '1', '1', NULL)' at line 1

alguna idea sobre este error?

mmm es un sistema para facturar pero ia estoi asta el cuello con el error

de repente me lo genero y no supe ni como se lo ise jajajaj

bueno , se les agradese por la ayuda
  #2 (permalink)  
Antiguo 01/09/2008, 11:09
Avatar de foreverOdd  
Fecha de Ingreso: noviembre-2007
Ubicación: Caracas
Mensajes: 489
Antigüedad: 16 años, 5 meses
Puntos: 14
Respuesta: ayuda con error

quiza si pones el codigo de donde se te genera el error sea mas facil ayudarte, pero reevisa bien la concatenacion de tu cadena sql
__________________
My path is lit by my own fire, I only go where I desire
  #3 (permalink)  
Antiguo 01/09/2008, 11:30
 
Fecha de Ingreso: septiembre-2008
Mensajes: 58
Antigüedad: 15 años, 7 meses
Puntos: 0
Respuesta: ayuda con error

pero mmmm dice ke es en la linea 1 pero ia lo cheke muchas veses y no se lo eh podido kitar

lo eswtoy asiendo en dreamweaver y pues practicamente este genera el codigoo
aunke otras veces io como para geneerar el iva o esas cosas

este es el codigo d ela pagina ke no me deja introdcudir los registros

<?php require_once('Connections/facturas.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$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"] == "form2")) {
$insertSQL = sprintf("INSERT INTO variables (fac_dia, fac_mes, fac_año, id_fact, fac_cantidad, fac_unidad, fac_desc, fac_p_unitario, fac_importe, fac_impcletra, fac_subtotal, fac_iva, fac_total) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['fac_dia'], "text"),
GetSQLValueString($_POST['fac_mes'], "text"),
GetSQLValueString($_POST['fac_allo'], "text"),
GetSQLValueString($_POST['id_fact'], "int"),
GetSQLValueString($_POST['fac_cantidad'], "text"),
GetSQLValueString($_POST['fac_unidad'], "text"),
GetSQLValueString($_POST['fac_desc'], "text"),
GetSQLValueString($_POST['fac_p_unitario'], "text"),
GetSQLValueString($_POST['fac_importe'], "text"),
GetSQLValueString($_POST['fac_impcletra'], "text"),
GetSQLValueString($_POST['fac_subtotal'], "text"),
GetSQLValueString($_POST['fac_iva'], "text"),
GetSQLValueString($_POST['fac_total'], "text"));

mysql_select_db($database_facturas, $facturas);
$Result1 = mysql_query($insertSQL, $facturas) or die(mysql_error());

$insertGoTo = "fac_final.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form2")) {
$insertSQL = sprintf("INSERT INTO variables (fac_dia, fac_mes, fac_fecha, fac_cantidad, fac_unidad, fac_desc, fac_p_unitario, fac_importe, fac_impcletra, fac_subtotal, fac_iva, fac_total) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['fac_dia'], "text"),
GetSQLValueString($_POST['fac_mes'], "text"),
GetSQLValueString($_POST['fac_fecha'], "text"),
GetSQLValueString($_POST['fac_cantidad'], "text"),
GetSQLValueString($_POST['fac_unidad'], "text"),
GetSQLValueString($_POST['fac_desc'], "text"),
GetSQLValueString($_POST['fac_p_unitario'], "text"),
GetSQLValueString($_POST['fac_importe'], "text"),
GetSQLValueString($_POST['fac_impcletra'], "text"),
GetSQLValueString($_POST['fac_subtotal'], "text"),
GetSQLValueString($_POST['fac_iva'], "text"),
GetSQLValueString($_POST['fac_total'], "text"));

mysql_select_db($database_facturas, $facturas);
$Result1 = mysql_query($insertSQL, $facturas) or die(mysql_error());

$insertGoTo = "fac_final.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}

$colname_fact = "-1";
if (isset($_GET['id'])) {
$colname_fact = (get_magic_quotes_gpc()) ? $_GET['id'] : addslashes($_GET['id']);
}
mysql_select_db($database_facturas, $facturas);
$query_fact = sprintf("SELECT * FROM cliente_fac WHERE id = %s", GetSQLValueString($colname_fact, "int"));
$fact = mysql_query($query_fact, $facturas) or die(mysql_error());
$row_fact = mysql_fetch_assoc($fact);
$totalRows_fact = mysql_num_rows($fact);

$colname_Recordset1 = "-1";
if (isset($_GET['id_fact'])) {
$colname_Recordset1 = (get_magic_quotes_gpc()) ? $_GET['id_fact'] : addslashes($_GET['id_fact']);
;
}
?><!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=utf-8" />
<title>insertar registros</title>
</head>

<body>
<script language = "Javascript">

function ivatotal() {
var subtotal = event.srcElement.value
var iva = Math.round(subtotal*.15*100)/100
var total = Math.round(subtotal*1.15*100)/100
document.form2.fac_iva.value=iva
document.form2.fac_total.value=total
}

</script>

<div><form id="form1" name="form1" method="post" action="">
<label></label>
<p align="left"><strong>No. cliente:</strong> <?php echo $row_fact['nom_clien']; ?></p>
<p align="left"><strong>Nombre del cliente:</strong> <?php echo $row_fact['dom_clien']; ?></p>
<p><strong>Domicilio:</strong> <?php echo $row_fact['ciud_clien']; ?></p>
<p><strong>Ciudad:</strong> <?php echo $row_fact['tel_clien']; ?></p>
<p><strong>R.F.C :</strong> <?php echo $row_fact['rfc_clien']; ?>
<label></label>
</p>
<p><a href="busqueda_cliente.php"></a> </p>
</form>

<p>&nbsp;</p>



<form action="<?php echo $editFormAction; ?>" method="post" name="form2" id="form2">
<table align="center">
<tr valign="baseline">
<td nowrap="nowrap" align="right">Fac_dia:</td>
<td><input type="text" name="fac_dia" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Fac_mes:</td>
<td><input type="text" name="fac_mes" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Fac_fecha:</td>
<td><input type="text" name="fac_fecha" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Fac_cantidad:</td>
<td><input type="text" name="fac_cantidad" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Fac_unidad:</td>
<td><input type="text" name="fac_unidad" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Fac_desc:</td>
<td><input type="text" name="fac_desc" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Fac_p_unitario:</td>
<td><input type="text" name="fac_p_unitario" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Fac_importe:</td>
<td><input type="text" name="fac_importe" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Fac_impcletra:</td>
<td><input type="text" name="fac_impcletra" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Fac_subtotal:</td>
<td><input type="text" name="fac_subtotal" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Fac_iva:</td>
<td><input type="text" name="fac_iva" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Fac_total:</td>
<td><input type="text" name="fac_total" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">&nbsp;</td>
<td><input type="submit" value="Insertar registro" /></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form2" />
</form>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><a href="busqueda_cliente.php"><img src="flecha_re.gif" width="22" height="22" /></a></p>
</div>
</body>
</html>
<?php
mysql_free_result($fact);
?>

de antemano muchas gtracias
  #4 (permalink)  
Antiguo 01/09/2008, 11:37
 
Fecha de Ingreso: agosto-2006
Mensajes: 173
Antigüedad: 17 años, 7 meses
Puntos: 1
Respuesta: ayuda con error

Creo que hace referencia a los valores NOT NULL y NULL, es decir o lo deja sin nada o le exije que tenga algo.

Si el campo con referencia NOT NULL esta vacio te da error
Si el campo con referencia NULL esta vacio no te da error
  #5 (permalink)  
Antiguo 01/09/2008, 11:43
Avatar de chiquirf  
Fecha de Ingreso: noviembre-2005
Ubicación: Madrid
Mensajes: 215
Antigüedad: 18 años, 5 meses
Puntos: 3
Respuesta: ayuda con error

revisa esta parte:

Cita:
$insertSQL = sprintf("INSERT INTO variables (fac_dia, fac_mes, fac_año, id_fact, fac_cantidad, fac_unidad, fac_desc, fac_p_unitario, fac_importe, fac_impcletra, fac_subtotal, fac_iva, fac_total) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
y esta:

Cita:
$insertSQL = sprintf("INSERT INTO variables (fac_dia, fac_mes, fac_fecha, fac_cantidad, fac_unidad, fac_desc, fac_p_unitario, fac_importe, fac_impcletra, fac_subtotal, fac_iva, fac_total) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
- Es la misma tabla "variables", si esto está apropósito así, mira si ninguno de los campos son NOT NULL

- Prueba cambiar en tu tabla y en el php el campo "fac_año" por "fac_anio" por si fuera por la ñ.


También revisa en:
Cita:
GetSQLValueString($_POST['campoForm'], "text"),
si la parte de "text" coincide con el formato de tu campo en MySQ, porque en fac_fecha, lo estas subiendo como "text" cuando debe ser "date" si es que en tu BBDD lo tienes como fecha.

revisado por encima puede ser q por esto te falle.

Saludos
  #6 (permalink)  
Antiguo 01/09/2008, 11:51
Avatar de Ronruby  
Fecha de Ingreso: julio-2008
Ubicación: 18°30'N, 69°59'W
Mensajes: 4.879
Antigüedad: 15 años, 9 meses
Puntos: 416
Respuesta: ayuda con error

Cita:
pero mmmm dice ke es en la linea 1 pero ia lo cheke muchas veses y no se lo eh podido kitar
Linea 1 de la Consulta MySQL, no del codigo PHP.

Revisa las sugerencias que te acaban de dar, el error esta ahi.

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 '±o) VALUES (NULL, '1', '1', '11', '1', '1', '11', '1', '1', '1', '1', '1', NULL)' at line 1
Ese error te indica que tienes un error en tu consulta.
Normalmente el error esta antes de la parte que te muestra de la consulta (La que puse en negrita)
  #7 (permalink)  
Antiguo 01/09/2008, 12:16
 
Fecha de Ingreso: septiembre-2008
Mensajes: 58
Antigüedad: 15 años, 7 meses
Puntos: 0
Respuesta: ayuda con error

ooooooooohhhhhhhhhhhh!!!!!

muchas gracias a todos son unos mmm. buenos en esto jejej

ia pude kitarselo, y aora solo me marca


Unknown column 'id_fact' in 'where clause'


pero creo ke si lo puedo kitar con un poko d epasiencia

muchisimas gracias les estoi muuy agradecido =)

a todos
  #8 (permalink)  
Antiguo 01/09/2008, 20:16
Avatar de GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 17 años, 11 meses
Puntos: 2135
Respuesta: ayuda con error

Ese error que te marca es que no existe la columna id_fact, checa que tengas bien definida esa columna.

Saludos.
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 20:15.