Welcome to Geeklog, Anonymous Sunday, September 01 2024 @ 01:27 am EDT
Geeklog Forums
Creating a block where people see top 10 players of a game server
Robinvd
Anonymous
Hello, i am very new into this business. Just installed geeklog today. Seems nice to me, so i want to use it for a game server i have.
I have a trackmania nations server running.
I want a block in my page that displays the top 10 players of my server.
I have created the function and the php block.
I used the following code in my lib_custom.php:
{
$sql1 = 'SELECT * FROM `tmos_players` WHERE rank < 11 ORDER by rank ASC';
$result1 = mysql_query($sql1);
$retval .= ("<TABLE>");
$retval .= "<tr>";
$retval .= ("<td>player</td>");
$retval .= ("<td>score</td>");
$retval .= ("<td>rank</td>");
$retval .= ("</tr>");
while ($Rij = mysql_fetch_array($result)){
$retval .= "<tr>";
$retval .= ("<td> $Rij[player] </td>n");
$retval .= ("<td> $Rij[score] </td>n");
$retval .= ("<td> $Rij[rank] </td>n");
$retval .= ("</tr>n");
}
$retval .= ("</TABLE>");
return $retval;
}
With that code i get the following error: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource.
I have read somewhere about etting an @ infront of mysql_fetch_array(), that removed the error, but didnt show the players.
Can somebody tell me what i am doing wrong and possibly explain me how to do it right?
Thank you very much.
Greetings
Robin
I have a trackmania nations server running.
I want a block in my page that displays the top 10 players of my server.
I have created the function and the php block.
I used the following code in my lib_custom.php:
Text Formatted Code
function phpblock_showplayers(){
$sql1 = 'SELECT * FROM `tmos_players` WHERE rank < 11 ORDER by rank ASC';
$result1 = mysql_query($sql1);
$retval .= ("<TABLE>");
$retval .= "<tr>";
$retval .= ("<td>player</td>");
$retval .= ("<td>score</td>");
$retval .= ("<td>rank</td>");
$retval .= ("</tr>");
while ($Rij = mysql_fetch_array($result)){
$retval .= "<tr>";
$retval .= ("<td> $Rij[player] </td>n");
$retval .= ("<td> $Rij[score] </td>n");
$retval .= ("<td> $Rij[rank] </td>n");
$retval .= ("</tr>n");
}
$retval .= ("</TABLE>");
return $retval;
}
With that code i get the following error: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource.
I have read somewhere about etting an @ infront of mysql_fetch_array(), that removed the error, but didnt show the players.
Can somebody tell me what i am doing wrong and possibly explain me how to do it right?
Thank you very much.
Greetings
Robin
8
8
Quote
Status: offline
jmucchiello
Forum User
Full Member
Registered: 08/29/05
Posts: 985
You are passing $result to fetch but you are creating the statement and returning it to $result1.
9
6
Quote
All times are EDT. The time is now 01:27 am.
- Normal Topic
- Sticky Topic
- Locked Topic
- New Post
- Sticky Topic W/ New Post
- Locked Topic W/ New Post
- View Anonymous Posts
- Able to post
- Filtered HTML Allowed
- Censored Content