trying to implement a facebook style pagination and i have been getting this error? Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource,

I am unsure of what this really means, however i aren't able to find a fix for this from searching, anything silly mistakes that stick out? here's the code :

    <?php
include('functions.php');


if(isset($_POST['lastmsg']) &&is_numeric($_POST['lastmsg']))
{
$lastmsg=$_POST['lastmsg'];
$query = mysql_query("SELECT * FROM links WHERE id>'$lastmsg' ORDER BY id ASC LIMIT 9 ");

while($result = mysql_fetch_array($query))
{
$msg_id=$result['id'];
$message=$result['link'];
?>

<li> <?php echo $message; ?> </li>
<?php
}


?>
<?php

if(mysql_num_rows($result)==9){
   ?>
<div class="facebook_style" id="facebook_style"> 
    <a id="<?php echo $message; ?>" href="#" class="load_more" >
        Show Older Posts <img src="arrow1.png" /></a> </div>
<?php
 }else {

    echo '  <div  id="facebook_style">
  <a  id="end" href="#" class="load_more" >No More Posts</a>
  </div>';

 }
}
?>

You need to pass mysql_num_rows() your $query value instead of your $results value. (Or you need to refactor your code to title $query to another thing like $query_result and pass that to mysql_num_rows().)

mysql_num_rows() needs a MySQL result resource, which inside your situation is came back by mysql_query(), which you've designated to $query.

$result, in comparison, is simply an assortment representing just one row from the result. (So a much better refactoring may be to relabel $result to $row and relabel $query to $result. You'll be able to leave your call to mysql_num_rows() out of the box.)

mysql_num_rows() needs an effect resource (inside your situation $query) as opposed to a row drawn from mysql_fetch_array().

if(mysql_num_rows($query )==9) {
  // etc...
}