php - Fixing errors in sql statement -
i have 3 tables of queried first table (users) result:
$string_users='19,20,21,22,25,26,27,28,29,30,31,32,33,34';
and want filter through 2 other tables friends , freinds_request , remove ids in numbers cud later poor understanding returns error:
warning: mysqli_num_rows() expects parameter 1 mysqli_result, boolean given in c:\xampp\htdocs\cebs\include\functions.php on line 825
i tried run query sql command - phpmyadmin see wrong:
select id users id not in (select user_one,user_two friends (user_one='18' , user_two in('19,20,21,22,25,26,27,28,29,30,31,32,33,34')) or (user_one in('19,20,21,22,25,26,27,28,29,30,31,32,33,34') , user_two='18')) , id not in( select to_user,from_user friend_reqest (to_user='18' , from_user in('19,20,21,22,25,26,27,28,29,30,31,32,33,34') or (to_user in('19,20,21,22,25,26,27,28,29,30,31,32,33,34') , from_user='18')) ) )
but mysql said:
#1241 - operand should contain 1 column(s)
below php code also:
function somepeopleyoumayknow(){ global $dbc_conn, $isloggin,$table_name,$friend_request_table,$friends_table ; $cu_school = getuser($isloggin,'cell_group'); //assuming $isloggin equal 18... $peopleids= mysqli_query($dbc_conn,"select id $table_name id !='$isloggin'"); $sql_num_rows = mysqli_num_rows($peopleids); if($sql_num_rows > 0){ while($run_peopleids= mysqli_fetch_array($peopleids)){ $users_ids[] = $run_peopleids['id']; } $string_users = implode(',',$users_ids); $sql = "select id $table_name id not in (select user_one,user_two $friends_table (user_one='$isloggin' , user_two in($string_users)) or (user_one in($string_users) , user_two='$isloggin')) , id not in( select to_user,from_user $friend_request_table (to_user='$isloggin' , from_user in($string_users) or (to_user in($string_users) , from_user='$isloggin')) )"; $filter_id_query = mysqli_query($dbc_conn,$sql); $fnrows = mysqli_num_rows($filter_id_query); if($fnrows > 0){ while($run_fiq=mysqli_fetch_array($filter_id_query)){ $uid[] = $run_fiq['id']; } echo $filtered_id_users = implode(',',$uid); } } }
below tables , data stored:
how can fix problem? thank you.
there issue remove single quote
inside in() otherwise consider single string:
(select user_one,user_two friends (user_one='18' , user_two in('19,20,21,22,25,26,27,28,29,30,31,32,33,34')) or (user_one in('19,20,21,22,25,26,27,28,29,30,31,32,33,34') , user_two='18')) , id not in( select to_user,from_user friend_reqest (to_user='18' , from_user in('19,20,21,22,25,26,27,28,29,30,31,32,33,34') or (to_user in('19,20,21,22,25,26,27,28,29,30,31,32,33,34') , from_user='18')) ) )
please update below:
(select user_one,user_two friends (user_one='18' , user_two in(19,20,21,22,25,26,27,28,29,30,31,32,33,34)) or (user_one in(19,20,21,22,25,26,27,28,29,30,31,32,33,34) , user_two='18')) , id not in( select to_user,from_user friend_reqest (to_user='18' , from_user in(19,20,21,22,25,26,27,28,29,30,31,32,33,34) or (to_user in(19,20,21,22,25,26,27,28,29,30,31,32,33,34) , from_user='18')) ) )
Comments
Post a Comment