undefined offset
Posted: Mon Oct 17, 2005 10:29 am
Hi,
the following code:
Is returning the following error codes:
Notice: Undefined offset: 10 in C:\server\Apache2\htdocs\tops\mysightings.php on line 68
Notice: Undefined offset: 9 in C:\server\Apache2\htdocs\tops\mysightings.php on line 68
Notice: Undefined offset: 8 in C:\server\Apache2\htdocs\tops\mysightings.php on line 68
Notice: Undefined offset: 7 in C:\server\Apache2\htdocs\tops\mysightings.php on line 68
Notice: Undefined offset: 10 in C:\server\Apache2\htdocs\tops\mysightings.php on line 68
Notice: Undefined offset: 9 in C:\server\Apache2\htdocs\tops\mysightings.php on line 68
Notice: Undefined offset: 8 in C:\server\Apache2\htdocs\tops\mysightings.php on line 68
Notice: Undefined offset: 7 in C:\server\Apache2\htdocs\tops\mysightings.php on line 68
Notice: Undefined offset: 10 in C:\server\Apache2\htdocs\tops\mysightings.php on line 68
Notice: Undefined offset: 9 in C:\server\Apache2\htdocs\tops\mysightings.php on line 68
Notice: Undefined offset: 8 in C:\server\Apache2\htdocs\tops\mysightings.php on line 68
Notice: Undefined offset: 7 in C:\server\Apache2\htdocs\tops\mysightings.php on line 68
Notice: Undefined offset: 10 in C:\server\Apache2\htdocs\tops\mysightings.php on line 68
Notice: Undefined offset: 9 in C:\server\Apache2\htdocs\tops\mysightings.php on line 68
Notice: Undefined offset: 8 in C:\server\Apache2\htdocs\tops\mysightings.php on line 68
Notice: Undefined offset: 7 in C:\server\Apache2\htdocs\tops\mysightings.php on line 68
I don't really know what Undefined offset means and i cant find an explanation anywhere else. Any ideas why it's returning this?
the following code:
Code: Select all
<html>
<body>
<centre><big><big>My Sightings</big></big></centre>
<br>
<br>
<table style="text-align: left; width: 156px; height: 32px;"
border="1" cellpadding="2" cellspacing="2">
<tbody>
<tr>
<td style="font-weight: bold; text-decoration: underline;">Number</td>
<td style="font-weight: bold; text-decoration: underline;">Staus</td>
<td style="font-weight: bold; text-decoration: underline;">Date
Sighted</td>
<td style="font-weight: bold; text-decoration: underline;">Location
Sighted</td>
<td style="font-weight: bold; text-decoration: underline;">Depot</td>
<td style="font-weight: bold; text-decoration: underline;">Pool
Code</td>
<td style="font-weight: bold; text-decoration: underline;">Livery</td>
<td style="font-weight: bold; text-decoration: underline;">Owner</td>
<td style="font-weight: bold; text-decoration: underline;">Name</td>
</tr>
<?php
$host = "localhost";
$user = "root";
$pass = "*****";
$db = "tops";
$user = $_GET['user'];
// open connection
$connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!");
// select database
mysql_select_db($db) or die ("Unable to select database!");
// create query
$query = "SELECT * FROM sightings
WHERE user='$user' ORDER BY 'number'";
// execute query
$result = mysql_query($query) or die ("Error in query: $query. ".mysql_error());
// see if any rows were returned
if (mysql_num_rows($result) > 0) {
// yes
// print them one after another
while(list($sightid, $user, $sightnumber, $day, $month, $year, $sightlocation) = mysql_fetch_row($result)) {
$fullsightdate = "$day/$month/$year";
/*
-------------------------------------------------------------------------------------------------
*/
// create query
$queryloco = "SELECT * FROM dloco
WHERE number='$sightnumber'";
// execute query
$resultloco = mysql_query($queryloco) or die ("Error in query: $queryloco. ".mysql_error());
// see if any rows were returned
if (mysql_num_rows($resultloco) > 0) {
// yes
// print them one after another
while(list($id, $class, $number, $status, $previous, $name_notes, $depot, $livery, $pool, $owner, $notes) = mysql_fetch_row($result)) {
echo "
<tr>
<td>$number</td>
<td>$status</td>
<td>$fullsightdate</td>
<td>$sightlocation</td>
<td>$depot</td>
<td>$pool</td>
<td>$livery</td>
<td>$owner</td>
<td>$name_notes</td>
</tr>
";
}
}
}
}
else {
// no
// print status message
echo "No rows found!";
}
// free result set memory
mysql_free_result($result);
// close connection
mysql_close($connection);
?>Notice: Undefined offset: 10 in C:\server\Apache2\htdocs\tops\mysightings.php on line 68
Notice: Undefined offset: 9 in C:\server\Apache2\htdocs\tops\mysightings.php on line 68
Notice: Undefined offset: 8 in C:\server\Apache2\htdocs\tops\mysightings.php on line 68
Notice: Undefined offset: 7 in C:\server\Apache2\htdocs\tops\mysightings.php on line 68
Notice: Undefined offset: 10 in C:\server\Apache2\htdocs\tops\mysightings.php on line 68
Notice: Undefined offset: 9 in C:\server\Apache2\htdocs\tops\mysightings.php on line 68
Notice: Undefined offset: 8 in C:\server\Apache2\htdocs\tops\mysightings.php on line 68
Notice: Undefined offset: 7 in C:\server\Apache2\htdocs\tops\mysightings.php on line 68
Notice: Undefined offset: 10 in C:\server\Apache2\htdocs\tops\mysightings.php on line 68
Notice: Undefined offset: 9 in C:\server\Apache2\htdocs\tops\mysightings.php on line 68
Notice: Undefined offset: 8 in C:\server\Apache2\htdocs\tops\mysightings.php on line 68
Notice: Undefined offset: 7 in C:\server\Apache2\htdocs\tops\mysightings.php on line 68
Notice: Undefined offset: 10 in C:\server\Apache2\htdocs\tops\mysightings.php on line 68
Notice: Undefined offset: 9 in C:\server\Apache2\htdocs\tops\mysightings.php on line 68
Notice: Undefined offset: 8 in C:\server\Apache2\htdocs\tops\mysightings.php on line 68
Notice: Undefined offset: 7 in C:\server\Apache2\htdocs\tops\mysightings.php on line 68
I don't really know what Undefined offset means and i cant find an explanation anywhere else. Any ideas why it's returning this?


