The following code is not working even though I've tested it by putting this on the page alone. To make this clear just after this query I'm doing a select query to display all the user in the DB.
$db->query("DELETE FROM Projet_Client WHERE username = '$_GET[d]'");
echo "<div class='alert alert-success text-middle'><strong>Succès</strong>, le
client a été supprimé.</div>";
Here is the "echo" of the query to show you how it looks like :
DELETE FROM Projet_Client
WHERE
username = 'a75ea99ce47306ec259d4c905bb9c3f762a531ee'
(I'm using my sql). Thank you.
I changed the code ant it looks like this :
$db->setAttribute(PDO::ATTR_EMULATE_PREPARES,false);
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING );
try {
$stmt = $db->prepare('DELETE FROM Projet_Client WHERE username= :username');
$stmt->bindParam(':username', $_GET['d']);
$stmt->execute();
} catch(Exception $e){
echo 'Exception -> ';
var_dump($e->getMessage());
}
However no exception are being throw.
The problem has been solved. I had to change the constraint with the foreign key : ON DELETE = CASCADE