unemployment Posted April 19, 2011 Share Posted April 19, 2011 How can I fix this error? Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given function fetch_most_recent_fans($ctag) { $sql = "SELECT `company_fans`.`company_id`, `company_fans`.`user_id`, `company_fans`.`fan_date`, `companies`.`companytag`, `users`.`firstname`, `users`.`lastname`, `users`.`username` FROM `company_fans` LEFT JOIN `companies` ON `companies`.`companyid` = `company_fans`.`company_id` LEFT JOIN `users` ON `users`.`id` = `company_fans`.`user_id` WHERE `companies`.`companytag` = {ctag} ORDER BY `company_fans`.`fan_date` DESC LIMIT 10"; $query = mysql_query($sql); $return = array(); while (($row = mysql_fetch_assoc($query)) !== false) { $return[] = $row; } return $return; } Quote Link to comment https://forums.phpfreaks.com/topic/234113-resource-boolean/ Share on other sites More sharing options...
dcro2 Posted April 19, 2011 Share Posted April 19, 2011 The query's obviously failing, so $query is false. Shouldn't this: WHERE `companies`.`companytag` = {ctag} be: WHERE `companies`.`companytag` = '{$ctag}' ? Quote Link to comment https://forums.phpfreaks.com/topic/234113-resource-boolean/#findComment-1203288 Share on other sites More sharing options...
unemployment Posted April 19, 2011 Author Share Posted April 19, 2011 that solves the boolean error but my array is empty Quote Link to comment https://forums.phpfreaks.com/topic/234113-resource-boolean/#findComment-1203292 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.