Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created June 5, 2019 18:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/ee225c8fe0c104eae0c2d3503239f0ad to your computer and use it in GitHub Desktop.
Save parzibyte/ee225c8fe0c104eae0c2d3503239f0ad to your computer and use it in GitHub Desktop.
<?php
include_once "base_de_datos.php";
$id = 1; // El id con el que se hace el where
$nombre = "ASD"; // El nuevo nombre
$edad = 2; // La nueva edad
$sentencia = $base_de_datos->prepare("UPDATE mascotas SET nombre = ?, edad = ? WHERE id = ?;");
$resultado = $sentencia->execute([$nombre, $edad, $id]); # Pasar en el mismo orden de los ?
if ($resultado === true) {
# OK
} else {
echo "Algo salió mal. Por favor verifica que la tabla exista, así como el ID del usuario";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment