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 26 27 28 29 30 31 32 33 34 35 36
| <?php
try {
$bdd = new PDO('mysql:host=localhost;dbname=guillaumemarie;charset=utf8', 'root', 'root');
// set the PDO error mode to exception
$bdd->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sql = "UPDATE commandes_bash SET commande= ':commande', description= ':description' WHERE id= ':id'";
// Prepare statement
$stmt = $bdd->prepare($sql);
$stmt->bindParam(':id', $_GET['id']);
$stmt->bindParam(':commande', $_POST['commande']);
$stmt->bindParam(':description', $_POST['description']);
// execute query
$stmt->execute();
// echo a message to say the UPDATE succeeded
echo $stmt->rowCount() . " records UPDATED successfully<br>";
echo "\nPDO::errorCode(): ", $stmt->errorCode();
echo "\nPDOStatement::errorCode(): ";
print $stmt->errorCode() ."<br>";
echo "\nPDOStatement::errorInfo():\n";
$arr = $stmt->errorInfo();
print_r($arr) ;
echo "<br>id:", $_GET['id'] . "<br>";
echo "Commande:", $_POST['commande'] . "<br>";
echo "Description:", $_POST['description'] . "<br>";
}
catch(PDOException $e)
{
echo $sql . "<br>" . $e->getMessage();
}
$bdd = null; |