It may be because your not initialising your array. ie:
        $partner_type = array();
        $partner_region = array();
PHP should automatically make it an array (if its not previously a different 
type) as soon as you do $partner_type[] but if you get no results from your 
query then it wont be an array.


Cheers,

Owen Prime
http://www.noggin.com.au

Nigel Dunn wrote:

> Hi,
> 
> If anyone can help me with this I'd be most appreciative.
> 
> I'm constructing 2 arrays of IDs from 2 different tables. Then I want to
> compare one to the other and only use the results that both arrays share
> in common to do a query loop that pulls the information for the related
> IDs to display.
> 
> The error I get from the code below is:
> 
> Warning: Argument #2 to array_intersect() is not an array in
> /usr/local/www/vhosts/trustbuild.co.nz/htdocs/partners_region.php on
> line 185
> 
> I cant see what is causing the problem.
> 
> <<< Start of My Existing Code >>>
> 
> $result = mysql_query("SELECT partner_id FROM partner_region WHERE
> region_id = '$r' ORDER BY partner_id");
> if ($row = mysql_fetch_array($result)) {
>    do {
>      partner_region[] = $row['partner_id'];
>    } while ($row = mysql_fetch_array($result));
> }
> 
> if (count($partner_region) != 0) {
>    array_unique($partner_region);
> }
> 
> $result2 = mysql_query("SELECT id FROM partner WHERE type = '$t' ORDER
> BY id");
> if ($row2 = mysql_fetch_array($result2)) {
>    do {
>      partner_type[] = $row2['id'];
>    } while ($row2 = mysql_fetch_array($result2));
> }
> 
> if (count($partner_type) != 0) {
>    array_unique($partner_type);
> }
> 
> $partner = array_intersect($partner_region, $partner_type);
> 
> if (count($partner) != 0) {
>    foreach ($partner as $p) {
>      $result3 = mysql_query("SELECT * FROM partner WHERE id = '$p'");
>      if ($row3 = mysql_fetch_array($result3)) {
>        do {
>          $company_name = $row3['company_name'];
>          $contact_name = $row3['contact_name'];
>          $physical_address = $row3['physical_address'];
>          $postal_address = $row3['postal_address'];
>          $city = $row3['city'];
>          $phone = $row3['phone'];
>          $fax = $row3['fax'];
>          $email = $row3['email'];
>          $url = $row3['url'];
>          $gst_number = $row3['gst_number'];
>          $company_age = $row3['company_age'];
>          $services = $row3['services'];
> $region = region($r);
> 
>          if ($count == 0) {
> echo "<tr><td bgcolor='#FFFFFF'><a href='closeup.php?id=$id'>$region
> $company_name</a><br>Type: $company_type<br>Contact Name:
> $contact_name<br>".nl2br($physical_address)."</td></tr>";
>            $count++;
>          } else {
>            echo "<tr><td bgcolor='#DDDDDD'><a
> href='closeup.php?id=$id'>$region $company_name</a><br>Type:
> $company_type<br>Contact Name:
> $contact_name<br>".nl2br($physical_address)."</td></tr>";
>            $count--;
>          }
>        } while ($row3 = mysql_fetch_array($result3));
>      }
>    }
> } else {
>    echo "There are no listings for your criteria. Please try again.<br>";
> }
> 
> <<< End of My Existing Code >>>
> 
> Thanks in advance for any help with this one,
> 
> Nigel Dunn

-- 
Cheers,

Owen Prime
http://www.noggin.com.au

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to