Ver Mensaje Individual
  #1 (permalink)  
Antiguo 06/11/2014, 21:28
Avatar de saulortega
saulortega
 
Fecha de Ingreso: septiembre-2011
Ubicación: Bogotá
Mensajes: 79
Antigüedad: 13 años, 6 meses
Puntos: 0
Insertar datos mysqli

Por consola en Mysql este comando funciona perfectamente:

SET NAMES 'utf8'; INSERT INTO datos (identificador, estado, nombre, clave, correo, telefono, ciudad, fecha_de_registro) VALUES ('1111', 'recién', 'Terce', 'contra', 'corre', '1234567890', 'ciudad', '2014-11-06');


Pero en PHP, este código:

Código PHP:
$agregar "SET NAMES 'utf8'; INSERT INTO datos (identificador, estado, nombre, clave, correo, telefono, ciudad, fecha_de_registro) VALUES ('1111', 'recién', 'Terce', 'contra', 'corre', '1234567890', 'ciudad', '2014-11-06');";
    
//Ejecutar instrucción:
    
$insertar $conexión->query($agregar); 
No funciona. Retorna 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 'INSERT INTO datos (identificador, estado, nombre, clave, correo, telefo' at line 1

¿Dónde está el error ?