2

i have a panel to confirm the users, there can be multiple selections with option select exc. I did the delete users part and its working perfect but with updating them to confirmed, i have some problems, i cant update the value of confirmation, here are the codes:

The Update Code from Panel :

if(isset($_POST["members"])) {
$members = $_POST["members"];
while(list($index, $member_id) = each($members)) {
confirmMembers($member_id); }
$msg = "Success";} 
else { $msg = "Error"; }

The confirmMembers Function :

function confirmMembers($member_id) {
global $db, $log;

try {
$confirm_member = "UPDATE `members` SET `confirmed` = 1 WHERE `member_id` = :member_id  LIMIT 1";
$confirm_member_do = $db->prepare($confirm_member);
$confirm_member_do->bindParam(':member_id', $member_id, PDO::PARAM_INT);
$confirm_member_do->execute();
return true;
} catch(PDOException $e) {
$log->logError($e." - ".basename(__FILE__));
return false;
}
    }

Thanks

14
  • Are you getting an error, or what happens? Commented Sep 11, 2012 at 2:39
  • getting success message but not updating in database, doesn't updating the 0 value to 1 Commented Sep 11, 2012 at 2:40
  • Does var_dump($confirm_member_do->errorInfo()) return anything? Commented Sep 11, 2012 at 2:49
  • Yes something like this : array(3) { [0]=> string(5) "00000" [1]=> NULL [2]=> NULL } Commented Sep 11, 2012 at 2:52
  • 1
    Are you sure there's an existing row with the member_id you're passing in? Try doing a SELECT before the UPDATE. Commented Sep 11, 2012 at 7:07

1 Answer 1

1

At last i found the mistake, for all who may make the same mistake, confirmed row is an enum value and must be equal to '1' instead of 1, that fixed the error and now it's working.

 $confirm_member = "UPDATE `members` SET `confirmed` = '1' WHERE `member_id` = :member_id  LIMIT 1";

Thanks for all who replied.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.