I,m going through a tutorial for pagination using php mysql and ajax.

I'm getting this error
Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\wamp\www\phpAjaxPagination\pageData.php on line 16

This is the file.

<?php

include_once('inc/dbConnect.inc.php');
include_once('inc/pagination.inc.php');

if(isset($_POST['pageId']) && !empty($_POST['pageId'])){
   $id=$_POST['pageId'];
}else{
   $id='0';
}

$pageLimit=PAGE_PER_NO*$id;
$query="SELECT post,link from pagination ORDER BY id DESC
LIMIY $pageLimit,".PAGE_PER_NO;
$res=mysql_query($query);
$count=mysql_num_rows($res);
$HTML='';
if($count > 0){
while($row=mysql_fetch_array($res)){
   $post=$row['post'];
   $link=$row['link'];
   $HTML.='<div>';
   $HTML.='<a href="'.$link.'" target="blank">'.$post.'</a>';
   $HTML.='</div><br/>';
}

}else{
    $HTML='No Data Found';
}

echo $HTML;

?>

Can anyone tell me the problem here?

Thanks...

i think query might be the problem there

$query="SELECT post,link from pagination ORDER BY id DESC LIMIY $pageLimit,".PAGE_PER_NO;

can you check the query once by manually at phpmysqladmin sql prompt?

(what i mean is copy the query here and paste and run at sql prompt)

let me know the OP?

on line 13 and 14 you mis-spelled LIMIT by LIMIY check your query

$query="SELECT post,link from pagination ORDER BY id DESC
LIMIY $pageLimit,".PAGE_PER_NO;

Needs to be:

$query="SELECT post,link from pagination ORDER BY id DESC
LIMIT $pageLimit,".PAGE_PER_NO;

Should work :)

Please don't use mysql_* commands, they're being depreciated.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.