So for some reason I need to check whether password should change or not. for that I use a variable to see if it's true or false.
$query = "UPDATE c_users SET ";
$query .= ($changepass) ? "user_pass = '$password', " : '' . "user_email = '$email', user_role = $role, display_name = '$nick', WHERE ID = $id";
echo $query . "<br>";
This works fine if ($changepass)
is false and if I print it:
UPDATE c_users SET user_email = 'example@example.com', user_role = 3, display_name = 'ROBOT', vip_status = 1 WHERE ID = 550
however if ($changepass)
is true, it doesn't work as expected. It should append user_pass = '$password',
to rest of the statement but instead it prints this:
UPDATE c_users SET user_pass = '$2y$10$l1TylEhM2oz4WdmlwWkcaupjpj1tt/HCyn7XGWbep1judDQb3E7e.',
notice that rest of the statement is missing. so query fails. how to fix it?