I want that admins can update rights for users, because admins can also add more rights I need to get the row from a $_GET and put it in the query;
if(isset($_GET['flip'], $_GET['userid'],$_GET['newval'])) {
switch($_GET['newval']) {
case 1:
$upd = $db->prepare("
UPDATE premissions
SET ? = '1'
WHERE userId = ?
");
break;
case 0:
default:
$upd = $db->prepare("
UPDATE premissions
SET ? = '0'
WHERE userId = ?
");
break;
}
$upd->execute(array($_GET['flip'], $_GET['userid']));
}
But now I get this error message:
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '? = '1' WHERE userId = ?' at line 2'
I understand that something is wrong with the syntax but I don`t know how to fix it.