0

I initialize my database with PDO and i use this parameter :

PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES UTF8",
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC

I do a sql request to my Database like that :

$sql = $db->query("DELETE FROM :equipement WHERE ID = :id", [
    ':equipement' => $_POST['type'],
    ':id' => (int)$_POST['id']
]);

var_dump($_POST) :

array(3) { ["id"]=> string(1) "4" ["type"]=> string(8) "portable" ["action"]=> string(6) "delete" }

my error :

Fatal error: Uncaught PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064

I think my error syntaxe is :equipement because it is remplacing by 'portable' and ' create trouble...

Did you know, what i'm supposed to do to fix it?

Catif
  • 33
  • 6

0 Answers0