Jump to content
Sign in to follow this  
Panta

WHERE IN SQL NOT WORKING WELL

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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...