elis Posted September 19, 2006 Share Posted September 19, 2006 Here is the code snippet I'm having trouble with: [code]$recip= strtolower(mysql_escape_string(trim(strip_tags($_POST['recip']))));$stringnew = nl2br(mysql_escape_string(trim(strip_tags($_POST['newmsg']))));$stringnew = str_replace($banned,$edited,$stringnew);$stringnew = str_replace("'", "^", $stringnew);$qCheck = "select * from TB_Users where penname = '$recip' limit 1";$rsCheck = mysql_query($qCheck) or die(mysql_error());$bresult = mysql_query("SELECT * FROM blocked_user WHERE username = '$recip'");$cresult = mysql_fetch_array( $bresult );$dresult = "SELECT * FROM blocked_user WHERE username = '$recip'";$eresult = mysql_query( $bresult );if (isset($_POST['newsent'])){if ($eresult[blocked]==$userpenname) { $output.="<br><center><font color=red>MESSAGE2</center></font>"; }elseif (mysql_num_rows($rsCheck)==0){$output.="<font color=red><center> - MESSAGE1</center>";} elseif ($recip==$userpenname){$output.="<br><center><font color=red>MESSAGE3</center></font>";} [/code]The two specific areas that I need help with are: (full text in code)elseif....$recip==$userpennameandelseif...$eresult[blocked]==$userpenname("$userpenname" is defined in another file - "$output" is similar to "echo")The problem is that "elseif...mysql_num_rows(rscheck)" is being correctly output, but the two I posted above are not printing.There is no error being reported.I assume there may be a mistake in the way I've selected the data, but I'm not sure.A second pair of eyes would really help.Thank you Link to comment https://forums.phpfreaks.com/topic/21333-syntax-not-being-read/ Share on other sites More sharing options...
Barand Posted September 20, 2006 Share Posted September 20, 2006 Try changing $eresult = mysql_query( $bresult );to $eresult = mysql_fetch_assoc( $bresult ); Link to comment https://forums.phpfreaks.com/topic/21333-syntax-not-being-read/#findComment-94992 Share on other sites More sharing options...
elis Posted September 20, 2006 Author Share Posted September 20, 2006 Thanks for your helpI tried what you said, but I still have the same problem Link to comment https://forums.phpfreaks.com/topic/21333-syntax-not-being-read/#findComment-95088 Share on other sites More sharing options...
btherl Posted September 20, 2006 Share Posted September 20, 2006 It's your variable names! They are driving me crazy! And they are causing bugs due to that confusion.[code]$qCheck = "select * from TB_Users where penname = '$recip' limit 1";$rsCheck = mysql_query($qCheck) or die(mysql_error());$rsBlock = mysql_query("SELECT * FROM blocked_user WHERE username = '$recip'") or die(mysql_error());$arrBlock = mysql_fetch_assoc( $rsBlock );if ($arrBlock['blocked'] == $userpenname) { ...[/code]When your variable names are consistent, it's easy to see what's going on. Cheking for errors on every query is also good practice. Link to comment https://forums.phpfreaks.com/topic/21333-syntax-not-being-read/#findComment-95127 Share on other sites More sharing options...
elis Posted September 20, 2006 Author Share Posted September 20, 2006 I tried changing the variables to what you suggested, but its still not blocking the request based on the "if" situation. Link to comment https://forums.phpfreaks.com/topic/21333-syntax-not-being-read/#findComment-95248 Share on other sites More sharing options...
elis Posted September 21, 2006 Author Share Posted September 21, 2006 ??? any other ideas? Link to comment https://forums.phpfreaks.com/topic/21333-syntax-not-being-read/#findComment-95748 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.