I'm trying to figure out why on earth the query below isn't working. Basically it checks if a checkbox is checked, if it is the checkboxes relating variable and therefore mysql record is set to 1. If the checkbox isn't checked its set to 0. I've added multiple different troubleshooting and error reporting snippets - no errors. Yet no success? This is driving me mad. Any advice is warmly welcomed! Thank you.
if(isset($_POST['updateUser'])){
$mysqli = mysqli_connect($config['host'],
$config['user'],
$config['pass'],
$config['db']);
foreach($_POST as $k => $v) {
$check[$k] = isset($_POST[$k]) ? 1 : 0;
}
$query = "UPDATE users_permissions SET editComments = ?,
editTopics = ?,
editArticles = ?,
autoApprove = ?,
allowArticleMod = ?,
courseAuthor = ?,
seeFinance = ?,
editUsers = ?,
editUsersPermissions = ?,
editSuperUsers = ?,
editWL = ?
WHERE
userid = ?";
$stmt = $mysqli->prepare($query);
$stmt->bind_param('iiiiiiiiiiii',
$check['editComments'],
$check['editTopics'],
$check['editArticles'],
$check['autoApprove'],
$check['allowArticleMod'],
$check['courseAuthor'],
$check['seeFinance'],
$check['editUsers'],
$check['editUsersPermissions'],
$check['editSuperUsers'],
$check['editWL'],
$profileData['userid']);
$profileData['userid']);
$stmt->execute();
}
UPDATED: Changes made to code to reflect suggestion made by @Floris