Johnson
Johnson

Reputation: 818

PHP: If no rows

if ( $bid != $USER OR mysql_num_rows($already) > 0) {
    echo "ok";
}

I have this line. I want "ok" to show, if $bid isn't the same as $USER OR if there doesn't exists any rows in the $already query.

What have I done wrong?

function show_block_Form($bid, $id, $USER){
$already = mysql_query("SELECT * FROM users_blocked WHERE bID = '$bid' AND uID = '$USER'") or die(mysql_error());
if($bid != $USER || mysql_num_rows($already)==0){
echo "ok"
}
}

Upvotes: 0

Views: 152

Answers (2)

Chris Laplante
Chris Laplante

Reputation: 29658

if($bid != $USER OR mysql_num_rows($already)>0){

should be

if($bid != $USER || mysql_num_rows($already)==0){

Upvotes: 1

Sarfraz
Sarfraz

Reputation: 382816

I want ok to show, if $bid isnt the smae as $USER *and* if there doesnt exists any rows in the $already query.

if($bid != $USER && mysql_num_rows($already) <= 0){

Upvotes: 1

Related Questions