mysqli_fetch_array()警告

时间:2014-07-21 07:50:07

标签: mysql mysqli

我连接到数据库并想要选择tweetid在我的数组中的行但它在响应中给了我警告。这是我的代码。如果有人帮助找出我的错误,将会感激不尽

   $con=mysqli_connect("localhost","root","6245","twitr");
   if (mysqli_connect_errno()) {
         echo "Failed to connect to MySQL: " . mysqli_connect_error();}
   $ids = join(',',$tweetids);
   $result = mysqli_query($con,"SELECT * FROM tweet WHERE tweetid in $ids");
   while($row = mysqli_fetch_array($result)) {}
   mysqli_close($con);

我的警告是:

 mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in

2 个答案:

答案 0 :(得分:3)

IN是一个函数,您需要将值设为

select * from table where col in (1,2,3);

http://dev.mysql.com/doc/refman/5.6/en/comparison-operators.html#function_in

答案 1 :(得分:0)

尝试使用FIND_IN_SET

$result = mysqli_query($con,"SELECT * FROM tweet WHERE find_in_set(tweetid,$ids)");