Can´t see the bug in this short code
Posted: Fri Dec 17, 2004 4:16 am
I'm getting this message from server but I can not see what's wrong:
FROM stock WHERE linea='macumba' AND almacen='Calle de Robocop' :You have an error in your SQL syntax near 'FROM stock WHERE linea='macumba' AND almacen='Calle de Robocop'' at line 1
FROM stock WHERE linea='macumba' AND almacen='Calle de Robocop' :You have an error in your SQL syntax near 'FROM stock WHERE linea='macumba' AND almacen='Calle de Robocop'' at line 1
Code: Select all
<?php
if (isset($linea) && $linea != -1)
$clauses[] = "linea='".$linea."'";
if (isset($almacen) && $almacen != -1)
$clauses[] = "almacen='".$almacen."'";
$query1 = 'FROM stock WHERE';
if (count($clauses) > 0)
$query1 .= ' '.join(' AND ', $clauses);
$pregunta1=mysql_query('SELECT count(*) '.$query1, $conexion) or die($query1.' :'.mysql_error());
$coincidencias = array_shift(mysql_fetch_row($pregunta1));
$herencia = (!empty($_GET['herencia']) && is_numeric($_GET['herencia'])) ? $_GET['herencia'] : 0;
$incremento = (!empty($_GET['incremento'])) ? $_GET['incremento'] : 0;
$aumento = $herencia + $incremento;
if ($aumento < 0)
$aumento = 0;
$pregunta2 = 'SELECT * ' . $query1 . ' LIMIT ' . $aumento . ', 10';
$result2=mysql_query($query1, $conexion) or die($query1.' :'.mysql_error());
$regporpagina=mysql_num_rows($pegar);
}
?>