Jump to content


Photo

Syntax not being read?


  • Please log in to reply
5 replies to this topic

#1 elis

elis
  • Members
  • PipPipPip
  • Advanced Member
  • 149 posts

Posted 19 September 2006 - 11:33 PM

Here is the code snippet I'm having trouble with:
$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>";}
	

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

#2 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,023 posts

Posted 20 September 2006 - 12:18 AM

Try changing

$eresult =  mysql_query( $bresult );

to

$eresult =  mysql_fetch_assoc( $bresult );
If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#3 elis

elis
  • Members
  • PipPipPip
  • Advanced Member
  • 149 posts

Posted 20 September 2006 - 04:38 AM

Thanks for your help
I tried what you said, but I still have the same problem

#4 btherl

btherl
  • Staff Alumni
  • Advanced Member
  • 3,893 posts
  • LocationAustralia

Posted 20 September 2006 - 06:20 AM

It's your variable names!  They are driving me crazy!  And they are causing bugs due to that confusion.

$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) { ...

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.

#5 elis

elis
  • Members
  • PipPipPip
  • Advanced Member
  • 149 posts

Posted 20 September 2006 - 12:29 PM

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

#6 elis

elis
  • Members
  • PipPipPip
  • Advanced Member
  • 149 posts

Posted 21 September 2006 - 12:01 AM

??? any other ideas?




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users