Jump to content

search not working


Tandem

Recommended Posts

I'm writing a search script for my game. It's supposed to search the database and echo the matches, but i'm having a problem with it.

I'm getting this error after it displays the results:
Warning: mysql_result() [function.mysql-result]: Unable to jump to row 4 on MySQL result index 7 in C:\Program....etc

Can anyone tell me why?

[code]<?php

echo <<<HERE
<div class="whitetext" align="center">\n
<form method="GET" action="find_Player.php">\n
Search:<input type="text" name="search" value=""><br />\n
<input type="submit" name="submitsearch" value="Search!">
HERE;

$find_player = $_GET['search'];
if (!empty($find_player)){
$find_playerdb = mysql_query("SELECT USERNAME FROM USERS WHERE USERNAME LIKE '$find_player%'");
$number_of_found_players = mysql_num_rows($find_playerdb);

echo "<br><br><b><u>Players Found</u></b><br><br>";

for ($i = 0; $i <= $number_of_found_players; $i++){

$search_result = mysql_result($find_playerdb, $i);

echo <<<HERE
<divalign="center"><a href="profile.php?username=$search_result">$search_result</a></div>
HERE;

if ($number_of_found_players == 0){
echo <<<HERE
<divalign="center">*Your search returned 0 results.</div>
HERE;
}
}
}

?>[/code]

Any help appreciated.
Link to comment
https://forums.phpfreaks.com/topic/15368-search-not-working/
Share on other sites

[code]
$result = mysql_query("select username from users where username like '%". $find_player ."%'");
$players_found = mysql_num_rows($result);
for($i=0; $i <= $players_found; $i++)
{
        $player = mysql($result, $i, "username");
        echo "<div align=\"center\">";
        echo "<a href=\"profile.php?username=$player\">$player</a>";
        echo "</div>";
}
[/code]

Try that. if it works let me know and ill explain the subtle differences.. theres very few
Link to comment
https://forums.phpfreaks.com/topic/15368-search-not-working/#findComment-62263
Share on other sites

I thought thats what you meant so i tried that aswell, now i'm getting all the results echo'd, but i'm getting the following error after them all:

Warning: mysql_result() [function.mysql-result]: Unable to jump to row 4 on MySQL result index 7 in C:\Program Files\Apache Group\Apache2\htdocs\Find_player.php on line 104

Not sure why :(
Link to comment
https://forums.phpfreaks.com/topic/15368-search-not-working/#findComment-62270
Share on other sites

| USERID | USERNAME      | PASSWORD                        | EMAIL
          | CASH      | LOCATION    | RANK    | GANG | POINTS | INBOXUNREAD |
MESSAGESSENT | LIFESTATUS | GUN  | BULLETS | PROTECTION | HEALTH | SIGNUPDATE
        | USER_LEVEL | ACTIVATED | LAST_ONLINE        |

It's a game about crime btw, just so you don't think i'm crazy or something :P
Link to comment
https://forums.phpfreaks.com/topic/15368-search-not-working/#findComment-62281
Share on other sites

It returns:

mysql> repair table users;
+-----------+--------+----------+---------------------------------------------------------+
| Table    | Op    | Msg_type | Msg_text  |
+-----------+--------+----------+---------------------------------------------------------+
| gng.users | repair | note    | The storage engine for the table doesn't support repair|
+-----------+--------+----------+---------------------------------------------------------+
1 row in set (0.00 sec)
Link to comment
https://forums.phpfreaks.com/topic/15368-search-not-working/#findComment-62283
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.