A previously unseen error message
Posted: Mon Oct 07, 2002 7:10 pm
Just got the following message when I tried to load a page:
Warning: 3 is not a valid MySQL result resource in /home/sites/site48/web/admin/adminsleaguetable.php on line 69
A bit baffling as the script had only processed the first entry, not got as far as three yet. Searched on MySql.com for an answer but saw nothing. Anyway, the page as a whole is as follows (as you can probably tell, it is meant to produce a league table based on admin pageviews):
Line 69 is this:
Does anyone have any ideas in regard to what is wrong?
Warning: 3 is not a valid MySQL result resource in /home/sites/site48/web/admin/adminsleaguetable.php on line 69
A bit baffling as the script had only processed the first entry, not got as far as three yet. Searched on MySql.com for an answer but saw nothing. Anyway, the page as a whole is as follows (as you can probably tell, it is meant to produce a league table based on admin pageviews):
Code: Select all
<? $pagetitle='Admins League Table';
require('auth.php');
include("$DOCUMENT_ROOT/templates/headeradmin.php");?>
<table width="600" border="0">
<tr>
<td valign="top" align="right">
Current time:
<? echo date ("l jS F\, Y\, g:ia"); ?>
<br>
Current timestamp:
<?
echo date ("U");
?>
</td>
</tr>
</table>
<table>
<tr>
<td>
Position
</td>
<td>
Name
</td>
<td>
Log-ins
</td>
<td>
Pageviews
</td>
<td>
Notes
</td>
</tr>
<?php
$position = 1;
$lastrelegationposition = 5;
$p1 = "#ffd700";
$p2 = "#fff68f";
$pmid = "#e0e0e0";
$prel = "#98fb98";
$blank = "#FFFFFF";
// Database constants
define("DATABASE_HOST", "***");
define("DATABASE_USER", "***");
define("DATABASE_PASSWORD", "***");
define("DATABASE_NAME", "***");
// Establish connection since we are going to use the database in every screen
$dbLink = mysql_connect(DATABASE_HOST, DATABASE_USER, DATABASE_PASSWORD);
if(!$dbLink) {
print "Unable to connect to the database, please contact Sysadmin asap.";
} else {
$dbUse = mysql_select_db(DATABASE_NAME, $dbLink);
}
// SQL QUERY
$sql = mysql_query("SELECT * FROM adminviews ORDER BY pageviews DESC");
//LOOP TO GET IT OUT OF THE DB - *NOTICE THE WAY I AM BREAKING OUT OF PHP, INTO HTML*
while($news = mysql_fetch_array($sql)){
if ($position == 1) {
echo "
<tr>
<td bgcolor="$p1">$position</td>
<td bgcolor="$p1">$newsїRealName]</td>
<td bgcolor="$p1">$newsїVisits]</td>
<td bgcolor="$p1">$newsїpageviews]</td>
<td bgcolor="#FFFFFF">League Leader</td>
</tr>";
$position++;
} else if ($position < 4) {
echo "
<tr>
<td bgcolor="$p2">$position</td>
<td bgcolor="$p2">$newsїRealName]</td>
<td bgcolor="$p2">$newsїVisits]</td>
<td bgcolor="$p2">$newsїpageviews]</td>
<td bgcolor="$blank">Champions League</td>
</tr>";
$position++;
} else if ($position > $lastrelegationposition) {
echo "
<tr>
<td bgcolor="$pmid">$position</td>
<td bgcolor="$pmid">$newsїRealName]</td>
<td bgcolor="$pmid">$newsїVisits]</td>
<td bgcolor="$pmid">$newsїpageviews]</td>
<td bgcolor="$blank"></td>
</tr>";
$position++;
} else {
echo "
<tr>
<td bgcolor="$prel">$position</td>
<td bgcolor="$prel">$newsїRealName]</td>
<td bgcolor="$prel">$newsїVisits]</td>
<td bgcolor="$prel">$newsїpageviews]</td>
<td bgcolor="$blank">Relegation candidate</td>
</tr>";
$position++;
}
mysql_free_result($sql);
mysql_close($dbLink);
}
echo "</table>";
include("$DOCUMENT_ROOT/templates/footeradmin.php");?>Code: Select all
while($news = mysql_fetch_array($sql)){