Hi,
Can anyone see where the error is in the script below?
It's telling me that the "Supplied argument is not a valid MySQL result resource in c:\phpdev\www\eball\ball_admin.php on line 17"
That line is: while ($row = mysql_fetch_array($result)) {
Any ideas?
Cheers,
micmac
<?
if(!isset($start)) $start = 0;
include ("include/header.inc.php");
include("include/dbconnect.php");
$row = mysql_fetch_row(mysql_query("SELECT COUNT(*) FROM ball"));
if($row[0] > 0){
$sql = mysql_query("SELECT * FROM ball WHERE active == 'yes' ORDER BY ball_name LIMIT " . $start . ", 20");
$result = mysql_query($sql);
echo "<table cellpadding=2 cellspacing=1 border=0>";
$alternate = "2";
while ($row = mysql_fetch_array($result)) {
$id = $row["ball_id"];
$firstname = $row["ball_name"];
if ($alternate == "1") {
$color = "#ffffff";
$alternate = "2";
}
else {
$color = "#efefef";
$alternate = "1";
}
echo "<tr bgcolor=$color><td>$firstname </td><td><a href='view.php?id=$id'>see details</a></td><td><a href='edit.php?id=$id'>edit record</a></td><td><a href='delete.php?id=$id' onClick=\"return confirm('Are you sure?')\">delete record</a></td></tr>";
}
echo "</table><br><br>";
} else {
echo "There are <b>no</b> balls currently available<br>";
echo "<br><a href='edit_ball.php'>add new ball</a><br>";
}
$query = "SELECT count(*) as count FROM $table";
$result = mysql_query($query);
$row = mysql_fetch_array($result);
$numrows = $row['count'];
if($start >= 20)
echo "<a href=\"" . $PHP_SELF . "?start=" . ($start - 20) . "\">Previous</a>";
if($numrows > ($start + 20))
echo " <a href=\"" . $PHP_SELF . "?start=" . ($start + 20) . "\">Next</a>";
?>