I'm trying to run the following code:
PHP Code:
178. $query "SELECT news_id, headline, summary, image, custom_linkname, " 
179. "custom_linkurl, date_added, news_stories.cat_id, category, " 
180. "DATE_FORMAT(date_added, 'Posted on %m/%d/%Y at %h:%i %p') AS " 
181. "post_date FROM news_stories, news_images, news_categories " 
182. "WHERE news_stories.img_id=news_images.img_id AND " 
183. "news_stories.cat_id=news_categories.cat_id AND " 
184. "MATCH(headline, story) AGAINST ('$term') ORDER BY " 
185. "date_added DESC LIMIT $limit, "STORIES_PER_PAGE;
186. $res mysql_query($query); 
187. $num mysql_num_rows($res); 
188. $i 0
189. echo "<H5>$query</h5>";
190. while ($news mysql_fetch_array($res)) {
...
... 
I've set up a FULLTEXT index on headline,story. I keep getting PHP errors:

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/*/public_html/inc/news_funcs.php on line 187

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/*/public_html/inc/news_funcs.php on line 190

Yet, when I copy/paste the query (I output it on the screen in the code above) to phpMyAdmin and run it, it works just fine. What could the problem be? I'm at a loss right now...

By the way, here's the query that gets printed on the screen that works right in phpMyAdmin:

PHP Code:
SELECT news_idheadlinesummaryimagecustom_linknamecustom_linkurldate_addednews_stories.cat_idcategoryDATE_FORMAT(date_added'Posted on %m/%d/%Y at %h:%i %p') AS post_date FROM news_storiesnews_imagesnews_categories WHERE news_stories.img_id=news_images.img_id AND news_stories.cat_id=news_categories.cat_id AND MATCH(headlinestoryAGAINST ('stapp'ORDER BY date_added DESC LIMIT 010