警告:array_intersect():参数#2不是第41行的C:\ wamp \ www \#\#.php中的数组

时间:2013-01-05 04:50:10

标签: php mysql phpmyadmin

当我将latitudelongitude传递给负值时,我收到此错误。当我通过正值时,它正常工作。需要一个解决方案。

错误:

1.Warning: array_intersect(): Argument #2 is not an array in C:\wamp\www\#\#.php on line 41
2.Warning: array_keys() expects parameter 1 to be array, null given in C:\wamp\www\#\#.php on line 42


$aaa=0;
$e=0;
$s=0;
$query1=mysql_query("select * from user_details where username!='$a' and availablestatus='1' and status='1'");
    while($row=mysql_fetch_array($query1))
    {
        $q[$e++]=$row['id'];
        $m=$row['username'];
        $k=$row['latitude'];
        $l=$row['longitude'];
        $aa[$aaa++]=1609.344 * 60 * 1.1515 * (180 / pi()) * acos(sin($i * pi() / 180) * sin($k * pi() / 180) + cos($i * pi() / 180) * cos($k * pi() / 180) * cos(($j - $l) * pi() / 180));

    }
    $res=array_combine($q,$aa);
    foreach($res as $val)
    {
        if($val>='0' && $val<='10000')
        {
            $ah[$s++]=$val;
        }
    }
    $rs=array_intersect($res,$ah);
    $rs1=array_keys($rs);

1 个答案:

答案 0 :(得分:0)

问题是if($val>='0' && $val<='10000')只允许正值。

如果这是预期行为,请在$ah=array();

之前定义foreach($res as $val)