cs1h Posted October 11, 2007 Share Posted October 11, 2007 Hi, Does anyone know why I am getting the following error. Fatal error: Undefined class name 'pager' in D:\Inetpub\vhost\myroho.com\httpdocs\alimit4.php on line 14 The code I am using is, <?php mysql_connect("localhost","xxx","xxx"); mysql_select_db("xxx") or die("Unable to select database"); // get the pager input values $page = $_GET['page']; $limit = 20; $result = mysql_query("select count(*) from items"); $total = mysql_result($result, 0, 0); // work out the pager values $pager = Pager::getPagerData($total, $limit, $page); $offset = $pager->offset; $limit = $pager->limit; $page = $pager->page; // use pager values to fetch data $query = "select * from jobs order by id limit $offset, $limit"; $result = mysql_query($query); // use $result here to output page content $result = mysql_query($sql); $num_rows = mysql_num_rows($result); if($num_rows == 0) { echo "<img src=http://www.myroho.com/sorry_no_match.png>"; } else { while($row = mysql_fetch_array($result)) { $Country = $row['country']; $Type = $row['type']; $More = $row['id']; $Title = $row['Title']; $Abs = $row['Abstract']; $Auth = $row['town']; echo "<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\"> <tr> <td width=\"14\" height=\"28\" background=\"line_left_corner_top.png\"> </td> <td height=\"28\" colspan=\"4\" background=\"line_top.png\"> </td> <td height=\"28\" background=\"line_right_corner_top.png\"> </td> </tr> <tr> <td width=\"14\" rowspan=\"3\" background=\"line_left.png\"> </td> <td width=\"250\" height=\"21\"><span class=\"style42\">$Title</span></td> <td width=\"154\" height=\"21\"> </td> <td width=\"14\"> </td> <td width=\"128\" height=\"128\" rowspan=\"3\"><img src=\"/searchthumbs/$Country$Type.png\" width=\"128\" height=\"128\" /></td> <td width=\"14\" rowspan=\"3\" background=\"line_right.png\"> </td> </tr> <tr> <td height=\"86\" colspan=\"2\"><span class=\"style41\">$Abs</span></td> <td width=\"14\"> </td> </tr> <tr> <td width=\"250\" height=\"19\"><span class=\"style43\">$Auth</span></td> <td width=\"154\" height=\"19\" align=\"left\" valign=\"bottom\"><span class=\"style39\">>></span> <span class=\"style40\"><a href=more2.php?id=$More>Read More</a> </span> <span class=\"style39\">>></span></td> <td width=\"14\"> </td> </tr> <tr> <td width=\"14\" height=\"19\" background=\"line_left_corner.png\"> </td> <td height=\"28\" colspan=\"4\" background=\"line_base.png\"> </td> <td width=\"14\" height=\"19\" background=\"line_right_corner.png\"> </td> </tr> <tr> <td width=\"14\" height=\"19\"> </td> <td height=\"21\" colspan=\"4\"> </td> <td width=\"14\" height=\"19\"> </td> </tr> </table>"; // output paging system (could also do it before we output the page content) if ($page == 1) // this is the first page - there is no previous page echo "Previous"; else // not the first page, link to the previous page echo "<a href=\"alimit4?page=" . ($page - 1) . "\">Previous</a>"; for ($i = 1; $i <= $pager->numPages; $i++) { echo " | "; if ($i == $pager->page) echo "Page $i"; else echo "<a href=\"alimit4.php?page=$i\">Page $i</a>"; } if ($page == $pager->numPages) // this is the last page - there is no next page echo "Next"; else // not the last page, link to the next page echo "<a href=\"alimit4.php?page=" . ($page + 1) . "\">Next</a>"; } } ?> If anyone can help it would be much appriciated. Thanks Colin Quote Link to comment https://forums.phpfreaks.com/topic/72779-fatal-error-undefined-class/ Share on other sites More sharing options...
kenrbnsn Posted October 11, 2007 Share Posted October 11, 2007 You're getting it because the class isn't defined in your script. That's what the error message says. Define it. Ken Quote Link to comment https://forums.phpfreaks.com/topic/72779-fatal-error-undefined-class/#findComment-367037 Share on other sites More sharing options...
cs1h Posted October 11, 2007 Author Share Posted October 11, 2007 Sorry this may seem like a dumb question but I don't what is meant by defining the class. I'm still very new to php. Can some one please help. Thanks Colin Quote Link to comment https://forums.phpfreaks.com/topic/72779-fatal-error-undefined-class/#findComment-367043 Share on other sites More sharing options...
trq Posted October 11, 2007 Share Posted October 11, 2007 The pager class is not part of php, meening that it needs to be defined by you. If you downloaded/copied this script from somewhere then you are missing the pager class. Quote Link to comment https://forums.phpfreaks.com/topic/72779-fatal-error-undefined-class/#findComment-367046 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.