I have a pretty simple task I want to perform, when I run the code one way it's fine, if I run it another way Fatal error: Uncaught exception 'Exception'...
Works
if (Input::get('userid')) {
$user_id = Input::get('userid');
$user->find($user_id);
$name = $user->data()->first_name;
if ($user->data()->active == 1) {
$user->update(array(
'active' => 0
));
Session::flash('userboard', $name.' Deactivated');
Redirect::to('admin.php');
} else {
$user->update(array(
'active' => 1
));
Session::flash('userboard', $name.' Activated');
Redirect::to('admin.php');
}
}
Doesn't Work
if (Input::get('adminid')) {
$user_id = Input::get('adminid');
$user->find($user_id);
$name = $user->data()->first_name;
if ($user->data()->active == 1) {
$user->update(array(
'group' => 1
));
Session::flash('userboard', $name.' Deactivated');
Redirect::to('admin.php');
} else {
$user->update(array(
'group' => 2
));
Session::flash('userboard', $name.' Activated');
Redirect::to('admin.php');
}
}
No matter which way I change it around I can't update the group. They are both int(11) in MySQL. I'm almost wondering if I need to delete the column and re add it? This group value is used for setting user permissions if that's of any help.
PDO errorInfo
Array ( [0] => 42000 [1] => 1064 [2] => 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 'group = '1' WHERE id = 6' at line 1 )