Tandem Posted July 23, 2006 Share Posted July 23, 2006 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....etcCan anyone tell me why?[code]<?phpecho <<<HERE<div class="whitetext" align="center">\n<form method="GET" action="find_Player.php">\nSearch:<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 More sharing options...
Tandem Posted July 23, 2006 Author Share Posted July 23, 2006 bump Link to comment https://forums.phpfreaks.com/topic/15368-search-not-working/#findComment-62257 Share on other sites More sharing options...
Branden Wagner Posted July 23, 2006 Share Posted July 23, 2006 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 Link to comment https://forums.phpfreaks.com/topic/15368-search-not-working/#findComment-62260 Share on other sites More sharing options...
Tandem Posted July 23, 2006 Author Share Posted July 23, 2006 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. Link to comment https://forums.phpfreaks.com/topic/15368-search-not-working/#findComment-62262 Share on other sites More sharing options...
Branden Wagner Posted July 23, 2006 Share Posted July 23, 2006 [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 More sharing options...
Tandem Posted July 23, 2006 Author Share Posted July 23, 2006 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 Link to comment https://forums.phpfreaks.com/topic/15368-search-not-working/#findComment-62264 Share on other sites More sharing options...
Branden Wagner Posted July 23, 2006 Share Posted July 23, 2006 sorry... my fault typo...change [code]$player = mysql($result, $i, "username");[/code]tochange [code]$player = mysql_result($result, $i, "username");[/code] Link to comment https://forums.phpfreaks.com/topic/15368-search-not-working/#findComment-62269 Share on other sites More sharing options...
Tandem Posted July 23, 2006 Author Share Posted July 23, 2006 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 104Not sure why :( Link to comment https://forums.phpfreaks.com/topic/15368-search-not-working/#findComment-62270 Share on other sites More sharing options...
Branden Wagner Posted July 23, 2006 Share Posted July 23, 2006 whats on line 104? Link to comment https://forums.phpfreaks.com/topic/15368-search-not-working/#findComment-62272 Share on other sites More sharing options...
Tandem Posted July 23, 2006 Author Share Posted July 23, 2006 [code]$player = mysql_result($result, $i, "username");[/code] Link to comment https://forums.phpfreaks.com/topic/15368-search-not-working/#findComment-62275 Share on other sites More sharing options...
Branden Wagner Posted July 23, 2006 Share Posted July 23, 2006 i think you might have some table corruption..run mysql from the command line... and do thisselect * from users;what are the column names in order? Link to comment https://forums.phpfreaks.com/topic/15368-search-not-working/#findComment-62276 Share on other sites More sharing options...
Tandem Posted July 23, 2006 Author Share Posted July 23, 2006 | 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 More sharing options...
Branden Wagner Posted July 23, 2006 Share Posted July 23, 2006 do a repair tablerepair table users;does it return anything? Link to comment https://forums.phpfreaks.com/topic/15368-search-not-working/#findComment-62282 Share on other sites More sharing options...
Tandem Posted July 23, 2006 Author Share Posted July 23, 2006 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 More sharing options...
Branden Wagner Posted July 23, 2006 Share Posted July 23, 2006 what version of MySQL are you running?what Operating System are you running? Link to comment https://forums.phpfreaks.com/topic/15368-search-not-working/#findComment-62284 Share on other sites More sharing options...
Tandem Posted July 23, 2006 Author Share Posted July 23, 2006 MySQL 5.0 and windows. Link to comment https://forums.phpfreaks.com/topic/15368-search-not-working/#findComment-62286 Share on other sites More sharing options...
Branden Wagner Posted July 23, 2006 Share Posted July 23, 2006 i tihnk u have some kind of corruption going on...cuz i believe all that php is correct.trydisk cleanupdefragrestarti dont know Link to comment https://forums.phpfreaks.com/topic/15368-search-not-working/#findComment-62287 Share on other sites More sharing options...
Tandem Posted July 23, 2006 Author Share Posted July 23, 2006 Ok, i will do, thankyou for the help. Link to comment https://forums.phpfreaks.com/topic/15368-search-not-working/#findComment-62288 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.