0

I can't figure out what is wrong with this code, it won't connect to the database right after it runs a successful query. Here is the snippet:

    $uresult = $db->query("SELECT uid FROM members WHERE email='$email'");
    $ures = $uresult->fetch_object(); $ures->uid;
    $_SESSION['ures'] = $ures;
    $db->close();

This is right after a prepared MySQLi statement.

TJ W
  • 51
  • 1
  • 6
  • include in the question the full context (the code above the shown code) – Constantin Galbenu Mar 22 '17 at 06:44
  • The rest is irrelevant because it works perfectly. The only thing of significance is a prepared statement that is carried out right before this. I don't see why that would impede the new query. I don't mean to sound stubborn, but there is a glaring problem with that snippet that someone more well-versed than I can point out. – TJ W Mar 22 '17 at 06:49
  • there are cases where a slow query bring the server down and a subsequent query will fail – Constantin Galbenu Mar 22 '17 at 06:51
  • 1
    $uresult = $db->query("SELECT uid FROM members WHERE email='$email'"); $ures = $uresult->fetch_object(); $ures=$ures->uid; $_SESSION['ures'] = $ures; $db->close(); – Nishit Manjarawala Mar 22 '17 at 06:52
  • If it's not the case with obvious typo from the above comment, you have to see the mysqli error to get the idea what's going wrong – Your Common Sense Mar 22 '17 at 07:21

0 Answers0