I'm trying this sql query, and it won't work:
<form name="modificarUsuario" action="" method="POST">
<h2>Modificación de Datos Personales</h2>
Username: <input type="text" name="username" />
Nombre Completo: <input type="text" name="nombre" />
Email: <input type="text" name="email" />
Clave: <input type="text" name="pass" />
<input type="submit" class="button" name="modificarDatos" value="Modificar datos">
<br>
</form>
$usuario = $_POST['username'];
$nombre = $_POST['nombre'];
$email = $_POST['email'];
$clave = $_POST['pass'];
$uid = 1;
$consulta = mysqli_prepare($conectar,
"UPDATE usuario
SET username = ?, pass = ?, name = ?, email = ?)
WHERE uid = '".$uid."'
");
if ($consulta) {
mysqli_stmt_bind_param( $consulta, 'ssss', $usuario, $clave, $nombre, $email);
mysqli_stmt_execute($consulta);
echo 'Se guardaron los cambios';
}
else {echo 'Hubo un error! El cambio no se guardó!';}
mysqli_stmt_close($consulta); //here's line 52
The error is:
PHP Warning: mysqli_stmt_close() expects parameter 1 to be mysqli_stmt, boolean given in ...
The database has an "usuario" table, with an "uid" field, which is an integer. All fields are correctly spelled and in the right order: uid, username, pass, name, email
I've read this post and this other post, and they both have interesting information about what could have been wrong. But I've checked and everything seems ok.