I am having really difficult time to find the mistake on my following code. It seems all the code is correct but I am having this warning error every time I try to run the page. Does anyone has a good knowledge on how to solve this problem? Yes, I have checked the connection, which is fine and the table called event is there with event_id in the database server. Thanks in advance.
The code generates records from the database and separates it according to the page number. I have set 1 record per page.
Warning: mysql_result() expects parameter 1 to be resource, boolean given in /Applications/XAMPP/xyz/xyz/xyz/event.php on line 89
<?php
$link = mysql_connect('localhost', '#', '#');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
$per_page = 1;
$pages_query = mysql_query("SELECT count(event_id) FROM event ORDER BY event_date");
$pages = ceil(mysql_result($pages_query, 0) / $per_page);
$page = (isset($_GET['page'])) ? (int)$_GET['page'] : 1;
$start = ($page - 1) * $per_page;
$query = mysql_query("SELECT * FROM event LIMIT $start, $per_page");
while ($query_row = mysql_fetch_assoc($query)) {
$event_name = $query_row['event_name'];
$event_info = $query_row['event_info'];
?>
Line 89 is
$pages = ceil(mysql_result($pages_query, 0) / $per_page);