Jump to content
  • 0

Error in Who is Online


Law

Question


  • Group:  Members
  • Topic Count:  7
  • Topics Per Day:  0.00
  • Content Count:  19
  • Reputation:   1
  • Joined:  01/21/12
  • Last Seen:  

Im making a script that show online players. I use the str_replace to show the job names(with the normal query show a number, currently incomplete im too lazy XD), but when I see a player I have a error:


[code]
Warning: mysql_result() [function.mysql-result]: Unable to jump to row 0 on MySQL result index 5 in /path/to/file.php on line 35


The script is there
<?php
mysql_connect(host,user,pass);
mysql_select_db(db);
$result = mysql_query("SELECT * FROM `char` WHERE online = '1'");
while ($row = mysql_fetch_array($result)) {
$JobsNumbers = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25');
$JobsNames = array('Novice', 'Swordman', 'Magician', 'Archer', 'Acolyte', 'Merchant', 'Thief', 'Knight', 'Priest', 'Wizard', 'Blacksmith', 'Hunter', '12', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24');
$id = $row["guild_id"];
$query = sprintf("SELECT name FROM guild WHERE guild_id='%s'", mysql_real_escape_string($id));
$result = mysql_query($query);
$guildname = mysql_result($result, 0);
echo "<tr>";
echo "<td> ".$row["name"]." </td><td>";
echo str_replace($JobsNumbers, $JobsNames, $row["class"]);
echo "</td><td>";

if ($guildname==NULL) {echo "wwww";}else{echo $guildname;};
echo "</td>";
echo "<td> ".$row["base_level"]."/".$row["job_level"]." </td>";
echo "</tr>";
}
;
?>

In the error say the line 35:

$guildname = mysql_result($result, 0);

Now, I see im using a wrong function(mysql_result), what function I should use? or how to fix it

Link to comment
Share on other sites

1 answer to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  47
  • Topics Per Day:  0.01
  • Content Count:  633
  • Reputation:   78
  • Joined:  11/14/11
  • Last Seen:  

i think you should be using mysql_fetch_array($result);

Link to comment
Share on other sites

×
×
  • Create New...