These errors, can someone tell me why?

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
Monotoko
Forum Commoner
Posts: 64
Joined: Fri Oct 26, 2007 4:24 pm

These errors, can someone tell me why?

Post by Monotoko »

Hmm, i am getting the following:

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/gamersne/public_html/tgl/tests/gotest.php on line 43

Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home/gamersne/public_html/tgl/tests/gotest.php on line 55

Fatal error: SQL in /home/gamersne/public_html/tgl/tests/gotest.php on line 55

the first error is making me :banghead:
the second error i dont even want to touch
and the 3rd error, AAAAAAAAAAAARRRRRRRRRRRRRRRRRRRRRRRGHHHHHHHHHHHHHHHHHHHHHHHHHHHHh

Code: Select all

<?
 
$con = mysql_connect("localhost","xxxxxxxxxxxxx","xxxxxxxxxxx");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
 
mysql_select_db("gamersne_mysys", $con);
 
echo "<table class='tborder' cellpadding='6' cellspacing='1' border='0' width='100%'
style='border-bottom-width:0px'>
<tr>
    <td class='tcat' width='100%'>
        <div align='center'>Members List</div></td>
    
</tr>
</table>
<table class='tborder' cellpadding='6' cellspacing='1' border='0' width='100%' align='center'>
<tr>
    <td class='alt1'><p align='center'><table border='1'>
<tr>
<td>Member</td>
<td>Gamers Level</td>
<td>Group</td>
<td>Clan</td>
<td>Joined</td>
<td>Posts</td>
<td>email</td>
</tr>
<tr>";
 
if (isset($_GET['pageno'])) 
{
 $pageno = $_GET['pageno'];
} 
else
{
 $pageno = 1;
}
 
$result = "SELECT * FROM members";
$query_data = mysql_num_rows($result);
$numrows = $query_data[0];
$rows_per_page = 15;
$lastpage      = ceil($numrows/$rows_per_page);
$pageno = (int)$pageno;
if ($pageno < 1) {
   $pageno = 1;
} elseif ($pageno > $lastpage) {
   $pageno = $lastpage;
}
$limit = 'LIMIT ' .($pageno - 1) * $rows_per_page .',' .$rows_per_page;
$query = "SELECT * FROM table $limit";
$result = mysql_query($query, $db) or trigger_error("SQL", E_USER_ERROR);
 
$name = $row['username'];
$lvl = $row['level'];
$group = $row['group'];
$email = $row['email'];
$clan = $row['clan'];
$posts = $row['posts'];
$joined = $row['joined'];
 
echo "<tr>
<td>$name</td>
<td>$lvl</td>
<td>$clan</td>
<td>$group</td>
<td>$joined</td>
<td>$posts</td>
<td>$email</td>
</tr>";
 
if ($pageno == 1) {
   echo " FIRST PREV ";
} else {
   echo " <a href='{$_SERVER['PHP_SELF']}?pageno=1'>FIRST</a> ";
   $prevpage = $pageno-1;
   echo " <a href='{$_SERVER['PHP_SELF']}?pageno=$prevpage'>PREV</a> ";
}
 
echo " ( Page $pageno of $lastpage ) ";
 
if ($pageno == $lastpage) {
   echo " NEXT LAST ";
} else {
   $nextpage = $pageno+1;
   echo " <a href='{$_SERVER['PHP_SELF']}?pageno=$nextpage'>NEXT</a> ";
   echo " <a href='{$_SERVER['PHP_SELF']}?pageno=$lastpage'>LAST</a> ";
}
?>
User avatar
liljester
Forum Contributor
Posts: 400
Joined: Tue May 20, 2003 4:49 pm

Re: These errors, can someone tell me why?

Post by liljester »

you didnt query the data from mysql. replace line 42 with:

Code: Select all

$result = mysql_query("SELECT * FROM members;");
in line 42 you set $result to a string value (not a result resource).
in line 43 you try to use mysql_num_rows() on a string value.. wich throws your first error.

in line line 55 it looks like youre not using the right rescource identifier for your mysql connection, your code shows it to be $con, but you try to use $db in your mysql_query... wich throws your second error.

and trigger_error() is generating your third error, because of the second error.
Post Reply