1

I use a library that helps me with db functionality. This is a valid syntax:

if ($memID = $db->get_var("SELECT id FROM users WHERE social_id = ".$_SESSION['user'])) {
   // user found
    $db->query("
          UPDATE users
          SET
            nameF = '".$NameF."',
            nameL = '".$NameL."'
            WHERE id = ".$memID."
          LIMIT 1");
} else {
   // user not found
}

I need to add additional checks:

if ($memID = $db->get_var("SELECT id FROM users WHERE social_id = ".$_SESSION['user']) ||
    $memID = $db->get_var("SELECT id FROM users WHERE email = '".$Email."' AND password IS NULL") ||
    ($_COOKIE['socid'] != '' && $memID = $db->get_var("SELECT id FROM users WHERE FIND_IN_SET(social_id, '".$_COOKIE['socid']."'))
 ){

}

But I think I'm over complicating this and introduce errors along the way. What am I doing wrong?

santa
  • 12,234
  • 49
  • 155
  • 255
  • 1
    Not sure if it's your problem, but you're missing your closing double quotation on the last query `'".$_COOKIE['socid']."')` should be `'".$_COOKIE['socid']."'")` – DiddleDot Dec 15 '15 at 17:22
  • Good catch. It fixed the broken page. – santa Dec 15 '15 at 17:37
  • 2
    **WARNING**: This looks [very insecure](http://bobby-tables.com/). You need to ensure any and all user parameters are [properly escaped](http://bobby-tables.com/php) or you are at serious risk of an application compromise. Whenever possible use prepared statements and placeholders to ensure you're not exposed to errors of that sort. – tadman Dec 15 '15 at 17:48

0 Answers0