Jump to content


Photo

search not working


  • Please log in to reply
17 replies to this topic

#1 Tandem

Tandem
  • Members
  • PipPipPip
  • Advanced Member
  • 251 posts

Posted 23 July 2006 - 01:18 AM

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?

<?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;
}
}
}

?>

Any help appreciated.

#2 Tandem

Tandem
  • Members
  • PipPipPip
  • Advanced Member
  • 251 posts

Posted 23 July 2006 - 01:32 AM

bump

#3 Branden Wagner

Branden Wagner
  • Members
  • PipPipPip
  • Advanced Member
  • 111 posts

Posted 23 July 2006 - 01:39 AM

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


#4 Tandem

Tandem
  • Members
  • PipPipPip
  • Advanced Member
  • 251 posts

Posted 23 July 2006 - 01:43 AM

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.

#5 Branden Wagner

Branden Wagner
  • Members
  • PipPipPip
  • Advanced Member
  • 111 posts

Posted 23 July 2006 - 01:49 AM

$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>";
}

Try that. if it works let me know and ill explain the subtle differences.. theres very few

#6 Tandem

Tandem
  • Members
  • PipPipPip
  • Advanced Member
  • 251 posts

Posted 23 July 2006 - 01:56 AM

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

#7 Branden Wagner

Branden Wagner
  • Members
  • PipPipPip
  • Advanced Member
  • 111 posts

Posted 23 July 2006 - 02:12 AM

sorry... my fault typo...
change
$player = mysql($result, $i, "username");
to
change
$player = mysql_result($result, $i, "username");


#8 Tandem

Tandem
  • Members
  • PipPipPip
  • Advanced Member
  • 251 posts

Posted 23 July 2006 - 02:15 AM

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 :(

#9 Branden Wagner

Branden Wagner
  • Members
  • PipPipPip
  • Advanced Member
  • 111 posts

Posted 23 July 2006 - 02:19 AM

whats on line 104?

#10 Tandem

Tandem
  • Members
  • PipPipPip
  • Advanced Member
  • 251 posts

Posted 23 July 2006 - 02:22 AM

$player = mysql_result($result, $i, "username");


#11 Branden Wagner

Branden Wagner
  • Members
  • PipPipPip
  • Advanced Member
  • 111 posts

Posted 23 July 2006 - 02:24 AM

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?

#12 Tandem

Tandem
  • Members
  • PipPipPip
  • Advanced Member
  • 251 posts

Posted 23 July 2006 - 02:35 AM

| 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

#13 Branden Wagner

Branden Wagner
  • Members
  • PipPipPip
  • Advanced Member
  • 111 posts

Posted 23 July 2006 - 02:38 AM

do a repair table

repair table users;

does it return anything?

#14 Tandem

Tandem
  • Members
  • PipPipPip
  • Advanced Member
  • 251 posts

Posted 23 July 2006 - 02:40 AM

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)

#15 Branden Wagner

Branden Wagner
  • Members
  • PipPipPip
  • Advanced Member
  • 111 posts

Posted 23 July 2006 - 02:48 AM

what version of MySQL are you running?
what Operating System are you running?

#16 Tandem

Tandem
  • Members
  • PipPipPip
  • Advanced Member
  • 251 posts

Posted 23 July 2006 - 02:53 AM

MySQL 5.0 and windows.

#17 Branden Wagner

Branden Wagner
  • Members
  • PipPipPip
  • Advanced Member
  • 111 posts

Posted 23 July 2006 - 02:58 AM

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

#18 Tandem

Tandem
  • Members
  • PipPipPip
  • Advanced Member
  • 251 posts

Posted 23 July 2006 - 02:59 AM

Ok, i will do, thankyou for the help.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users