mysql - PHP function not returning TRUE -


i trying create function check if user subscribed or not, code doesn't work, doesn't return true if user subscribed.

here example of code.

function is_subscribed($email) {     global $dbc;      $result = mysqli_query($dbc,"select * users email = $email");      if(mysqli_num_rows($result) > 0) {         while($row = mysqli_fetch_array($result)) {             if($row['subscribed'] == 'yes') {                  return true;              } else {                 return false;             }         }     } }  $user_email = $_session['email'];  if(is_subscribed($user_email)) {     echo "yes!"; } 

you need wrap $email quotes because string. so:

select * users email = '$email' 

Comments

Popular posts from this blog

inversion of control - Autofac named registration constructor injection -

verilog - Systemverilog dynamic casting issues -

ios - Change Storyboard View using Seague -