Jump to content

WHERE IN SQL NOT WORKING WELL


Panta

Recommended Posts

Please i dont know why this is not working fine, 

$unsetmerge=$flash->query("UPDATE `user` SET merged='no' WHERE email IN ('$emailuser','$togethelp')");

it will SET '$emailuser' to no but will not do same for '$togethelp'   . i dont know what am not doing right and when i print $togethelp it contains the proper data

Link to comment
Share on other sites

First stop using this query as it is not protected. Use prepared statements in order to protect your data from possible attacks.

CODE:

try {

    $sql = "UPDATE `user` SET merged = `no` WHERE email IN (:emailuser, :togethelp)";
    $unsetmerge = $flash->prepare($sql);
    $unsetmerge->bindParam(":emailuser", $emailuser);
    $unsetmerge->bindParam(":togethelp", $togethelp);
    $unsetmerge->execute();

} catch (PDOException $e) {
	echo "Error: " . $e->getMessage();
}

Using the catch function you can catch the error is being throw by the sql if there is any.

This should do your job.

Edited by Gabrielphp
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...