I am trying to retrieve the number of rows based on this query in wordpress:
protected function wp_has_facility($fid)
{
//global $wpdb;
$fid = intval($fid);
$sql = "SELECT post_id FROM wprf_postmeta WHERE meta_value = '".$fid."' AND meta_key = 'facility_id'";
$result = mysql_query($sql) or die(mysql_error());
$num_rows = mysql_num_rows($result);
echo $num_rows;
return $num_rows;
}
$num_rows returns 0 when this function is ran.
If I echo the query string and run it in phpmyadmin, it selects successfully giving me a number of rows.
After further investigation it looks like when I hardcode the meta_value it will give me a row count. But if I'm populating the string with variables it doesn't work.
Any ideas?
$thing_id?