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

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -