Jump to content

Archived

This topic is now archived and is closed to further replies.

elis

Syntax not being read?

Recommended Posts

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==$userpenname
and
elseif...$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

Share this post


Link to post
Share on other sites
Try changing

$eresult =  mysql_query( $bresult );

to

$eresult =  mysql_fetch_assoc( $bresult );

Share this post


Link to post
Share on other sites
Thanks for your help
I tried what you said, but I still have the same problem

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
I tried changing the variables to what you suggested, but its still not blocking the request based on the "if" situation. 

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.