Page 1 of 1

Undefined Index Error with paging script

Posted: Wed Dec 15, 2004 4:18 pm
by Catz
Hi All

I have a simple db table containing fields for ID, Ref # and Image name. The Ref field is NOT a unique key field. Below is my php script. It displays the first record, but as soon as I click on the "next" button, I get the error "Undefined Index: Ref on....."

Code: Select all

<?php
error_reporting(E_ALL);
@require_once("scripts/pager.php");
$p = new Pager;
$limit = 1;
$start = $p->findStart($limit);

@require("scripts/connect.php");
$T = $_REQUEST["Ref"];
$count = mysql_num_rows(mysql_query("SELECT * FROM images WHERE Ref = '$T'"));
$pages = $p->findPages($count, $limit);
$result = mysql_query(("SELECT * FROM images WHERE Ref = '$T' LIMIT ".$start.", ".$limit), $connection) or die(mysql_error());
$next_prev = $p->nextPrev($_GET['page'], $pages);
while ($display = mysql_fetch_array($result)) {
$ID=$display["ID"];
$Ref=$display["Ref"];
$Image=$display["Image"]; 

echo "<p>$next_prev</p>";
echo "<p><img border='0' src='photos/$Image'</p>
?>
Thnx!

Posted: Wed Dec 15, 2004 4:25 pm
by rehfeld
learn how and why to use isset() and empty()

your problem is on the line php reported in the error msg.