
Fatal error en PHP y no se como resolverlo
Publicado por Jorge (1 intervención) el 16/11/2022 16:49:51
Estaba haciendo un trabajo en PHP y me salio este error y la verdad no se como solucionarlo, espero puedan ayudarme. También les dejo al final el archivo winrar con el código completo. Y he de decir que ya verifiqué con el MySQL y tengo todos los datos de las variables bien, no tengo ningún error con eso.
Fatal error: Uncaught mysqli_sql_exception: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'nacimiento, usuario, clave) VALUES ('', '', '', '', '', '')' at line 1 in C:\xampp\htdocs\HTML\T1\modelo\DatosModel.php:22 Stack trace: #0 C:\xampp\htdocs\HTML\T1\modelo\DatosModel.php(22): mysqli->query('INSERT INTO dat...') #1 C:\xampp\htdocs\HTML\T1\control\Datos.php(30): Datos_model->insertar('', '', '', '', '', '') #2 C:\xampp\htdocs\HTML\T1\core\routes.php(18): DatosController->guarda() #3 C:\xampp\htdocs\HTML\T1\index.php(12): cargarAccion(Object(DatosController), 'guarda') #4 {main} thrown in C:\xampp\htdocs\HTML\T1\modelo\DatosModel.php on line 22
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<?php
class Datos_model {
private $db;
private $datos;
public function __construct(){
$this->db = Conectar::conexion();
$this->datos = array();
}
public function get_datos(){
$sql = "SELECT * FROM datos";
$resultado = $this->db->query($sql);
while($row = $resultado->fetch_assoc()){
$this->datos[] = $row;
}
return $this->datos;
}
public function insertar($cedula, $nombre, $apellido, $fecha_nacimiento, $usuario, $clave){
$resultado = $this->db->query("INSERT INTO datos (cedula, nombre, apellido, fecha nacimiento, usuario, clave) VALUES ('$cedula', '$nombre', '$apellido', '$fecha_nacimiento', '$usuario', '$clave')");
}
}
Fatal error: Uncaught mysqli_sql_exception: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'nacimiento, usuario, clave) VALUES ('', '', '', '', '', '')' at line 1 in C:\xampp\htdocs\HTML\T1\modelo\DatosModel.php:22 Stack trace: #0 C:\xampp\htdocs\HTML\T1\modelo\DatosModel.php(22): mysqli->query('INSERT INTO dat...') #1 C:\xampp\htdocs\HTML\T1\control\Datos.php(30): Datos_model->insertar('', '', '', '', '', '') #2 C:\xampp\htdocs\HTML\T1\core\routes.php(18): DatosController->guarda() #3 C:\xampp\htdocs\HTML\T1\index.php(12): cargarAccion(Object(DatosController), 'guarda') #4 {main} thrown in C:\xampp\htdocs\HTML\T1\modelo\DatosModel.php on line 22
Valora esta pregunta


0