database - Debugging a Simple IF Statement in PHP -
code
does not work --
$u = $_session['username']; while($responseanswer=mysqli_fetch_array($rquery)){ if($responseanswer['onuser']=='$u'&&$responseanswer['response']=='') { echo "awesome"; } }
works
$u = $_session['username']; while($responseanswer=mysqli_fetch_array($rquery)){ if($responseanswer['onuser']&&$responseanswer['response']=='') { echo "awesome"; } }
how resolve this? $u fine. thanks.
single quotes not interpolated variables inside them. should work:
if($responseanswer['onuser']==$u && $responseanswer['response']=='')
but 1 thing note, i'd highly suggest format cod ebetter. include spaces appropriate, , indent scope. code become:
$u = $_session['username']; while ($responseanswer=mysqli_fetch_array($rquery)) { if ($responseanswer['onuser'] == $u && $responseanswer['response'] == '') { echo "awesome"; } }
Comments
Post a Comment