From: cac3882000 at yahoo dot com dot ar
Operating system: Windows XP
PHP version: 5.3Git de 2013-06-14 (Git)
Package: MySQLi related
Bug Type: Bug
Bug description:PHP : 5.3.5; Apache: 2.2.17; MySQL: 5.5.8
Description:
------------
<?php
error_reporting( E_ALL );
$link = "";
$result = "";
// test01-php CARGA DE DATOS A LA BASE
// Listo los campos a cargar transferidos con el método POST del
formulario y a
través de $_POST.
//
echo "Apellido: " , $_POST['apellido'], "<br>";
echo "Nombres: " , $_POST['nombre'], "<br>";
echo "Nro. Doc: " , $_POST['ndoc'] ,"<br>";
echo "Calle : " , $_POST['calle'], "<br>";
echo "Numero: " , $_POST['numcalle'], "<br>";
echo "Importe: " , $_POST['importe'], "<br>";
echo "Telefono: " , $_POST['telefono'], "<br>";
echo "Fecha: " , $_POST['fecha'], "<br>";
//
// Verifico los campos antes de cargarlos a la base.
//
if(isset($_POST['apellido']) && !empty($_POST['apellido']) &&
isset($_POST['nombre']) && !empty($_POST['nombre']) &&
isset($_POST['ndoc']) && !empty($_POST['ndoc']) &&
isset($_POST['calle']) && !empty($_POST['calle']) &&
isset($_POST['numcalle']) && !empty($_POST['numcalle']) &&
isset($_POST['importe']) && !empty($_POST['importe']) &&
isset($_POST['telefono']) && !empty($_POST['telefono']))
{
$link = mysqli_connect('localhost', '', '','bd_clientes');
if (!$link) {
die('Error de Conexión (' . mysqli_connect_errno() . ') '
. mysqli_connect_error()); exit();
} else {
echo 'Ãxito ... se accedió a la BD !!' .
mysqli_get_host_info($link), "<br>";
}
} else {
echo 'Faltan completar campos obligatorios, se anula la carga
!!';
exit(); echo "<br>";
}
// Desactivo autocommit
mysqli_autocommit($link, FALSE);
//
$result = mysqli_query($link,"INSERT INTO tb_cliente
(id,apellido,nombres,numdoc,calle,numcalle,telefono,importe)
VALUES (''','{$_POST['apellido']}','{$_POST['nombre']}','
{$_POST['ndoc']}','{$_POST['calle']}','
{$_POST['numcalle']}','{$_POST['telefono']}','
{$_POST['importe']}");
if (!$result)
{
echo ("Mensaje de error: " . mysqli_error($link)), "<br>";
echo ("Código de error: " . mysqli_errno($link)), "<br>";
echo ("Error - SQLSTATE " . mysqli_sqlstate($link)), "<br>";
}
// Activo la transacción
mysqli_commit($link);
// Cierro la base
mysqli_close($link);
?>
Test script:
---------------
Respuesta del pgm.:
Apellido: Gomez Pereda
Nombres: Miguel Horacio
Nro. Doc: 8103661
Calle : De la Rosa
Numero: 1595
Importe: 738500.75
Telefono: 4701-3394
Ãxito ... se accedió a la BD !!localhost via TCP/IP
Mensaje de 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 'Gomez Pereda','Miguel Horacio',' 8103661','De la Rosa',' 159' at line
2
Código de error: 1064
Error - SQLSTATE 42000
Expected result:
----------------
La idea es la de cargar una tabla con datos transferidos desde un
formulario HTML
con el método POST a través de $_POST. El pgm. los lista previamente para
comprobar que fueron transferidos, pero al momento de ejecutar la
instrucción
mysqli_query para hacer el INSERT INTO, da el error indicado (1064 -
SQLSTATE
42000), que, como principiante que soy, no interpreto, a pesar de agotar
las
posibilidades de solución por medio de pruebas y búsqueda de la
documentación
sobre el tema; si bien es un procedimiento común y frecuente, no dispongo
a quien
recurrir y quedo estancado. Solicito me oriente y me diga en donde me
equivoqué a
fin de subsanar el error. Desde ya mi agradecimiento tanto por su gestión
como por
la deferencia del tiempo dedicado. Muchas gracias
PD.
Ejecutado en Windows XP
Bajo: I Explorer y Mozilla Firefox 21.0
Versiones: PHP : 5.3.5; Apache: 2.2.17; MySQL: 5.5.8
Actual result:
--------------
Estructura de la tabla destino de los datos:
Campo Tipo Cotejamiento Atributos Nulo Predeterminado
Extra Acción
id int(11) No None AUTO_INCREMENT
apellido varchar(25) latin1_swedish_ci No None
nombres varchar(30) latin1_swedish_ci No None
numdoc int(10) No None
calle varchar(25) latin1_swedish_ci No None
numcalle varchar(5) latin1_swedish_ci No None
telefono varchar(10) latin1_swedish_ci No None
importe decimal(8,0) No None
Marcar todos/as / Desmarcar todos Para los elementos que están marcados:
________________________________________
Vista de impresión Vista de relaciones Planteamiento de la estructura
de
tabla
Añadir campo(s) Al final de la tabla Al comienzo de la tabla Después
de
________________________________________
Ãndices:
Acción Nombre de la clave Tipo Ãnico Empacado Campo
Cardinalidad Cotejamiento Nulo Comentario
PRIMARY BTREE SÃ No id 0 A
index BTREE SÃ No telefono 0 A
--
Edit bug report at https://bugs.php.net/bug.php?id=65041&edit=1
--
Try a snapshot (PHP 5.4):
https://bugs.php.net/fix.php?id=65041&r=trysnapshot54
Try a snapshot (PHP 5.3):
https://bugs.php.net/fix.php?id=65041&r=trysnapshot53
Try a snapshot (trunk):
https://bugs.php.net/fix.php?id=65041&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=65041&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=65041&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=65041&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=65041&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=65041&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=65041&r=support
Expected behavior: https://bugs.php.net/fix.php?id=65041&r=notwrong
Not enough info:
https://bugs.php.net/fix.php?id=65041&r=notenoughinfo
Submitted twice:
https://bugs.php.net/fix.php?id=65041&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=65041&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=65041&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=65041&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=65041&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=65041&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=65041&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=65041&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=65041&r=mysqlcfg