0

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...

5
Contributors
4
Replies
5
Views
4 Years
Discussion Span
Last Post by diafol
0

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?

0
$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.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.