i have this weird problem and i dont know how to make it work.
the problem appears after i consider the OR statement.without or statement the first part is working .
So idont how to use this statement in mysql.
i hope someone can help me.
Down is my script.

$po=$_POST['postid'];
$poster=$_POST['poster'];
$user=$_SESSION['user'];

 $checkz=mysql_query("SELECT DISTINCT poster FROM postcomment WHERE ((postid='$po') and (poster !='$poster')) OR ((postid='$po') and (poster !='$user'))"); 
         $countt=mysql_num_rows($checkz);	
		 
		 if($countt>0){
		 
		   while($row=mysql_fetch_array($checkz)){

		   $postern=$row['poster'];
                echo" $postern<br/>";
             }
}

my problem is here

$checkz=mysql_query("SELECT DISTINCT poster FROM postcomment WHERE ((postid='$po') and (poster !='$poster')) OR ((postid='$po') and (poster !='$user'))");

i eve tried this but didn`t work either.

$checkz=mysql_query("SELECT DISTINCT poster FROM postcomment WHERE ((postid='$po') and ((poster !='$poster')  or (poster !='$user')));

I couldn't notice anything wrong in the query. Did you check the result only for the second part like the following and get the results you expected ?

$checkz=mysql_query("SELECT DISTINCT poster FROM postcomment WHERE   ((postid='$po') and (poster !='$user'))");

yeah!when i checked the result for the second part i got the result i expected.
Thats why i`m wondering what might be wrong here wit the OR statement.

The query looks fine, what is the difference between $poster and $user ?

Actually i`m trying to send notifications to people.
$poster is the owner of the post and $user is the one commenting,which means the logged in member which can happen.
so below is my whole script....when i was writing it seemed to be fine but when i started to test it ,is when i experience this weird problem.
So the problem is in line 63-64.
other parts of the script are fine even the DISTINCT FUNCTION ALSO OK.

<?php   session_start();
include"config.php";
$user=$_SESSION['user'];
$userid=$_SESSION['id'];
$names=$_SESSION['name'];

if(isset($_POST['submitpostcomment'])){

$po=$_POST['postid'];
$poster=$_POST['poster'];
$comment=$_POST['comment'];


$query = "INSERT INTO postcomment  SET comment='$comment',poster='$user',postid='$po'" ;
$result=mysql_query($query);
$statusid2= mysql_insert_id();
    if($result) {

     echo"Comment posted successfully<br/>";
	 
	 
	 //NOTIFICATION TO THE PEOPLES
 //select the gender of the poster to be used if his/her commenting own photo
 $ddaaa=mysql_query("SELECT genders FROM  profile WHERE users='$user'");
       $sszz=mysql_fetch_array( $ddaaa);
        $jinsia=$sszz['genders'];
	    if($jinsia==p){
		$jinsia='his';
		}else{
		 $jinsia='her';
		}
 
 
 
 
   //check to see if the one commenting is the owner of the post
     if($poster!=$user) {
	 
      	 
    //select email of the owner of post
      $dd=mysql_query("SELECT emails,genders FROM  profile WHERE users='$poster'");
       $ss=mysql_fetch_array($dd);
       $owneremail=$ss['emails'];
	   
	   //INSERT INTO NOTICATION TABLE
	  mysql_query("INSERT INTO notification SET type='post',action='commented your post',typeid='$po',sender='$user',receiver='$poster',status='0'");
      
      //send notification to the owner of the photo to the email address
	   /*
        $from="From:web@web.com\r\n";
         $to="$owneremail";
        $subject="$name Commented Your blog post";
        $content="$name Commented Your post, to see the comment  click link below \r\n http://myweb.com/postview.php?contid=$po";
        if($content){
           mail($to, $subject, $content,$from);
          }*/
		  
		 
     /* CHECK TO SEE IF  OTHER PEOPLE ALSO COMMENTED,EXCLUDING LOGGED user AND OWNER OF THE POSTER 
        IF SOMEOTHER PEOPLE COMMENTED THEN TELL someone commented a post that u also commented.
		SOMEONE COMMENTED MORE THAN ONCE THEN SEND ONLY ONE NOTIFICATION
	*/
		 $checkz=mysql_query("SELECT DISTINCT poster FROM postcomment WHERE postid='$po'  AND  ((poster!='$user') OR (poster !='$poster'))"); 
         $countt=mysql_num_rows($checkz);	
		 
		 if($countt>0){
		 
		   while($rw=mysql_fetch_array($checkz)){
		   $postern=$rw['poster'];
		    //select the email of the person who also commented
			$querya=mysql_query("SELECT emails FROM  profile WHERE users='$postern'");
            $rra=mysql_fetch_array($querya);
            $com_email=$rra['emails'];
			
			echo"<font color=red size=6>$postern</font><br/>";
			
			
			
		 //INSERT INTO NOTICATION TABLE
	      mysql_query("INSERT INTO notification SET type='post',action='commented the post that u also commented',typeid='$po',sender='$user',receiver='$postern',status='0'");
			/*
		
		//then send notification   to their emails
			 $from="From:web@web.com\r\n";
             $to="$com_email";
             $subject="$name Commented post that u also commented";
             $content="$name Commented post that u also commented, to see the comment  click link below \r\n http://web.com/postview.php?contid=$po";
             if($content){
              mail($to, $subject, $content,$from);
             }
		   */
		   
		   
		   
		   
		   }
		}  
       	

    }elseif($poster==$user){
	 $user=$_SESSION['user'];
	include"config.php";
	     /*if the owner of the post is Commenting */
		 $checkAA=mysql_query("SELECT  DISTINCT poster FROM postcomment WHERE ((postid='$po') and (poster !='$user'))"); 
         $count78=mysql_num_rows($checkAA);	
		 
		 if($count78 !=0){
		   while($row_Q=mysql_fetch_array($checkAA)){
		   $commen=$row_Q['poster'];
		    //select the email of the person who also commented
			$queryD=mysql_query("SELECT emails FROM  profile WHERE users='$commen'");
            $rr=mysql_fetch_array($queryD);
            $com_email=$rr['emails'];
			
			//INSERT INTO NOTICATION TABLE
	       mysql_query("INSERT INTO notification SET type='post',action='commented on $jinsia own  post',typeid='$po',sender='$user',receiver='$commen',status='0'");
			
			/* 
			//then send notification  to other people who also contributed to ur topic
			 $from="From:web@web.com\r\n";
             $to="$com_email";
             $subject="$name commented on $jinsia own  post;
             $content="$name commented on $jinsia own  post, to see the comment  click link below \r\n http://web.com/postview.php?contid=$po";
             if($content){
              mail($to, $subject, $content,$from);
             }*/
		   
		   
		   
		   
		   
		   }
		}   

		
		
		
		
		
		}

 //END OF NOTIFICATION TO THE PEOPLES//











}











}


?>

You could try something like this:

$array = array($user, $poster);

$checkz=mysql_query("SELECT DISTINCT poster FROM postcomment WHERE postid='$po' AND poster NOT IN ('".array($array)."')

okey=))i will try this and inform you .

This also didn`t work.
What its doing is taking all poster frm where id=$post without considering $array .
this is what i`m also getting with my script.
If u have time for this please can u test it for me .
i mean u create a simple comment system where all people who comments will be notified when somebody else comment including the owner of the comment.
sometimes i think may be mysql have changed their commands .why is OR and NOT IN not working ?

Hey ..
1. Try to echo out the query and paste it in mysql.......
2. r u getting any error?
3. whether the output of the query returns null or any value...

i`m not getting any error!!!
when i echo the result it gives the values names of all the poster where id='$po' which is postid.
what i want is to exclude the $user the logged member and $poster the owner of the poster in my query.
ACTUALLY its VERY STRANGE error! thats why i`m asking if somebody can test it for me...to see where i`m going wrong.

Hey,
So i think you got the required result , but need to removal something for this rit?
Whether you need to remove $user and $poster from the result or query ?
Or explain me what s ur requirement or output

Maybe you can try AND instead of OR and see what that does.

Should it not be,

$checkz=mysql_query("SELECT DISTINCT poster FROM postcomment WHERE postid='".$po."' AND ((poster !='".$poster."')  OR (poster !='".$user."'")));

I can't see what the extra brackets were doing and I capitalized the AND and OR, I find it easier to read the statement then.

@CFROG,its unbelievable....after i tried the AND instead of OR everything worked as i wanted..

$checkz=mysql_query("SELECT DISTINCT poster FROM postcomment WHERE postid='".$po."' AND ((poster !='".$poster."')  AND (poster !='".$user."'))");

when u suggested that,i didn`t even test coz for me it did not sound correct.
Just today decided to try it,and this is just bcoz there was no way i could solve this question(tried alot of tricks) And HURAAAAAAAAAAAAAAAAAAA it worked.
THANKX TO ALL WHO CONTRIBUTED ON THIS THREAD.

LOL ... now that hurts, you didn't even try it.

yeah man!i`m sorry.
i was very sure that the OR can`t be replaced by AND...
i real appreciate for ur suggestion.