Very good! I am doing a small practice to remember after having been studying again the php and in knowledge of the MySqli (style procedure), when creating the database and the corresponding tables. I have never seen this error after making the form to add records from a table and then fill it out and this appears:
Editarusuario.php
<?php
$msg = $Usuario = $Nombre = $Apellido = $ID_perfil = $ID_estado = $password = $fecha_actual = NULL;
if(isset($_POST['editar'])) {
$Usuario = $_POST['usuario'];
$Nombre = $_POST['apellido'];
$ID_perfil = $_POST['id_perfil'];
$ID_estado = $_POST['id_estado'];
$password = $_POST['password'];
$fecha_actual = $_POST['fecha'];
if ($Usuario && $Nombre && $ID_perfil && $ID_estado && $password && $fecha_actual) {
$link = mysqli_connect("localhost", "root", "", "webpractica");
if(mysqli_connect_errno()) {
printf("Falló la conexión: $s\n", mysqli_connect_error());
exit();
}
$query = mysqli_query($link, "UPDATE Usuario SET Usuario = '$Usuario', Nombre = '$Nombre', password = '$password', Fecha_Creacion = '$fecha_actual' WHERE ID_perfil = '$id_perfil' AND ID_estado = '$id_estado')");
if(!$query) {
printf("Error: %s\n", mysqli_error($link));
} else {
$msg = "Los datos se editaron correctamente";
}
}
}
echo $msg;
?>
This error has something related by the relation of the tables or is it the query or is it allowed to modify the restrictions of the Foreign Key?
I look forward to your comments and solutions. Regards!
EDIT: After studying intensely about mysql and trying to insert the tables without the need for PHP (unless I do it right, I modified it a bit by putting AND, I did not know if it was necessary for the two foreign keys and the error is shown in new images, the database is updated with PK and FK.)
EDIT 2: I discovered that when cutting the relation of the user table with the appendix, it works with the other tables, but when I left filling the table with php everything was fine, but, I was trying to connect the relation id_status of the user table with id_estado of annex, pulls the same error. (FK with FK) I leave the details of the contents of the tables.