I've written a simple module to query an external database to list and display properties for sale. All aspects of the code work okay except for the listing piece, which relies on db_rewrite_sql() to construct an argument for pager_query() and then display a list.
db_set_active('rmls');
$sql_cnt = "SELECT COUNT(DISTINCT(id)) from residential where ($coutput) AND ListPrice>=$low AND ListPrice<=$high";
$result = pager_query(db_rewrite_sql("SELECT ml,city,ListPrice,TotalSQFT,NumberofBedrooms,TotalBathrooms,NumberofPhotos from residential where ($coutput) AND ListPrice >=$low AND ListPrice <=$high ORDER BY ListPrice DESC"), 20,0,$sql_cnt);
db_set_active('default');
If I am logged in as the superuser, the list displays properly, though the function throws an error:
Table 'rmls.node_access' doesn't exist query: SELECT COUNT(*) FROM node_access WHERE nid = 0 AND ((gid = 0 AND realm = 'all')) AND grant_view >= 1 in /var/www/sjp/includes/database.mysql.inc on line 121.
If I am not logged in, or am logged in as a user other than the superuser, the code does not return a result and throws the following error: