Undefined Index Error with paging script

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Catz
Forum Newbie
Posts: 8
Joined: Wed Dec 15, 2004 4:08 pm

Undefined Index Error with paging script

Post 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!
rehfeld
Forum Regular
Posts: 741
Joined: Mon Oct 18, 2004 8:14 pm

Post by rehfeld »

learn how and why to use isset() and empty()

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