-1

Possible Duplicate:
mysql_fetch_array() expects parameter 1 to be resource, boolean given in select

I am trying to get posts from my mybb database, and then display it in the homepage. I wish to sort it by newest thread first, however when I attempt it it fails with this message:

Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /home/ interitu/public_html/index.php

Code used:

    <?php
$con = mysql_connect("","","");
// I HAVE REMOVED THE CONNECTION DETAILS FOR DATABASE SECURITY
if (!$con)
{
die('Could not connect: ' . mysql_error());
}

mysql_select_db("interitu_forums", $con);

$result = mysql_query("SELECT * FROM mybb_posts ORDER BY tid ASC WHERE fid='4' LIMIT 
5");

while($row = mysql_fetch_array($result))
{

And the code goes on to stuff not relevant (HTML content).

Community
  • 1
  • 1
Lord_Lewes
  • 11
  • 1
  • 2

2 Answers2

1
SELECT * 
FROM mybb_posts
WHERE fid='4'
ORDER BY tid ASC  
LIMIT 5

The where clause needs to be before the order by clause.

juergen d
  • 195,137
  • 36
  • 275
  • 343
0

order of executing sql : select, from, where, Group by, having, order by, limit. select * from FROM mybb_posts
WHERE fid='4'
ORDER BY tid ASC 
LIMIT 5


logan
  • 7,413
  • 36
  • 107
  • 178