Jump to content

[SOLVED] IN statement with array


ohdang888

Recommended Posts

$result = mysql_query("SELECT COUNT(id) FROM `friends` WHERE (`1`='$id2' AND `2` IN ($friends_of_1)) OR (`2`='$id2' AND `1` IN ($friends_of_1))")or die(mysql_error());

 

$friends_of_1 is an array with mulitple values...

basically what this is doing is counting the mutual friends.

 

i'm getting this error:

Unknown column 'Array' in 'where clause'

Link to comment
https://forums.phpfreaks.com/topic/118391-solved-in-statement-with-array/
Share on other sites

UPDATE: GOT IT WORKING. THANKS

 

 

ok i;'ve got this:

 

and this not the error from using $in

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') OR (`2`='4' AND `1` IN (7, 2, 8, 3, ))' at line 1

 

<?php
$in = " IN (";
foreach($friends_of_1 as $value){
$value = $sec->clean($value); 
$in = $in.$value.', ';
}
$in = $in.' )';
echo $in;

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.