-1

I have the following query on an external file to a WordPress install querying a BuddyPress table. I am receiving no errors yet the results are displaying?

$the_pro = "". implode(", ", $user) ."";

    $query ="SELECT 
        (SELECT value  FROM wp_bp_xprofile_data WHERE 'user_id' IN (" . $the_pro . ") AND field_id = '2') as 'prof',
        (SELECT value  FROM wp_bp_xprofile_data WHERE 'user_id' IN (" . $the_pro . ") AND field_id = '3') as 'address',
        (SELECT value FROM wp_bp_xprofile_data WHERE 'user_id' IN (" . $the_pro . ") AND field_id = '4') AS 'city',
        (SELECT value FROM wp_bp_xprofile_data WHERE 'user_id' IN (" . $the_pro . ") AND field_id = '5') AS 'state',
        (SELECT value FROM wp_bp_xprofile_data WHERE 'user_id' IN (" . $the_pro . ") AND field_id = '6') AS 'zip',
        (SELECT value FROM wp_bp_xprofile_data WHERE 'user_id' IN (" . $the_pro . ") AND field_id = '7') AS 'link'
        ";
     $results = mysql_query($query);
 while($row = mysql_fetch_array($results)) { 

?>

        <div style="padding-bottom:4px; border-bottom:#CCC 1px solid;" >
        <div class="prof"><a href="#" onClick="myClick(0);"><?php echo $row['prof']; ?></a></div>
        <div class="address"><span style="margin-bottom:3px;"><?php echo $row['address']; ?></div>
        <div class="local"><?php echo $row['city']; ?>, <?php echo $row['state']; ?> &nbsp;<?php echo $row['zip']; ?></div>
        </div>
        <?php 
  }?>
soehli
  • 25
  • 3

1 Answers1

0

Please try adding: if (!$result) { die('Invalid query: ' . mysql_error()); } so you know if there's an error or it really returned an empty result.

MiGs
  • 13
  • 3