I have an application that is to handle favorites (my favorite internet pages) and the code in charge of updating the users does not update me, it only changes the name to a 0 and the rest is left as it is. I put some images and tell me if you need me to upload something else.
This is the table to manage the users, the 3rd , 4th and 5th users show what I told them:
And this is the code in charge of updating the users:
<?php
session_start();
$db = new SQLite3('favoritos.db');
$usuarioantiguo = $_SESSION['usuario'];
$usuario = $_POST['usuario'];
$contrasena = $_POST['contrasena'];
$nombre = $_POST['nombre'];
$apellido = $_POST['apellido'];
$edad = $_POST['edad'];
$resultado = $db->query("UPDATE usuarios SET usuario='".$usuario."' AND contrasena='".$contrasena."' AND nombre='".$nombre."' AND apellido='".$apellido."' AND edad=".$edad." WHERE usuario='".$usuarioantiguo."'");
$db->close();
//Vuelvo a gestionusuarios.php
echo "
<html>
<head>
<meta http-equiv='REFRESH' content='0;url=gestionusuarios.php'>
</head>
</html>
";
?>
The failure occurs because there is an error in your SQL. The fields that are updated are not separated by
AND
but by a comma (,
). The syntax of aUPDATE
should be like this:When you put a
AND
what you are doing is assigningusuario
the value of the logical operation to the field:You have to change the code to be something like this:
and then the
UPDATE
should work without problems.