mysql - PHP function not returning TRUE -
this question has answer here:
- when use single quotes, double quotes, , backticks in mysql 10 answers
- reference - error mean in php? 29 answers
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
Post a Comment