Jump to content

Archived

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

Tandem

search not working

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.

Share this post


Link to post
Share on other sites
First off: In plain english explain to me what you want the search to search for.
second: you have way too much code, so let me know and ill cut it down for you

Share this post


Link to post
Share on other sites
I want it to search for results that either match the search, or begin with the search. Eg.for the latter, if i searched t, i would expect Tandem to come up.

Share this post


Link to post
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

Share this post


Link to post
Share on other sites
I'm getting this x6:
Warning: mysql(): supplied argument is not a valid MySQL-Link resource in C:\Program Files\Apache Group\Apache2\htdocs\Find_player.php on line 103

Share this post


Link to post
Share on other sites
sorry... my fault typo...
change [code]$player = mysql($result, $i, "username");[/code]
to
change [code]$player = mysql_result($result, $i, "username");[/code]

Share this post


Link to post
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 :(

Share this post


Link to post
Share on other sites
[code]$player = mysql_result($result, $i, "username");[/code]

Share this post


Link to post
Share on other sites
i think you might have some table corruption..
run mysql from the command line... and do this

select * from users;

what are the column names in order?

Share this post


Link to post
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

Share this post


Link to post
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)

Share this post


Link to post
Share on other sites
i tihnk u have some kind of corruption going on...
cuz i believe all that php is correct.
try

disk cleanup
defrag
restart

i dont know

Share this post


Link to post
Share on other sites

×

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.