0
$assault_checker=mysql_query("SELECT * FROM assaults WHERE host_id='".$_SESSION['user']."' OR guest_id='".$_SESSION['user']."' AND status='0'");
$assault_checker=mysql_num_rows($assault_checker);

I keep getting the wrong expected result. I just want to count the number of rows where the user id is in host_id or guest_id. Also the status row should be 0.

What am I missing?

Bhargav Rao
  • 50,140
  • 28
  • 121
  • 140

1 Answers1

3

yes you should use brackets, your query should be:

$assault_checker=mysql_query("SELECT * FROM assaults WHERE (host_id='".$_SESSION['user']."' OR guest_id='".$_SESSION['user']."') AND status='0'");
Gouda Elalfy
  • 6,888
  • 1
  • 26
  • 38