cdoyle Posted August 4, 2008 Share Posted August 4, 2008 Hi, I need help with an existing search that I have in my game. I'm trying to make it so a user can search for either dead or alive players, by selecting from a dropdown option. A player is considered dead, if their ID is listed in the medical_ward table. If their ID is not listed in that table, then they are alive. The medical ward is something I've added to the game, the search that comes with ezRPG didn't consider someone dead this way. It would just consider them dead if HP==0 I was getting some help on another forum, and we were able to come up with the following. It causes errors, but I think we are getting closer. Because the game is written using Adodb, they weren't able to help any further and recommended I try and find someone who might have a better understanding of it. # //Construct query # # if($_GET['alive'] == 0) { //Assuming a value of 0 means that the 'dead' option was selected # $query .= ' INNER JOIN medical_ward ON players.id = medical_ward.playerdead_ID '; # } # # $query .= ($_GET['username'] != "")?"`username` LIKE ? and ":""; # $query .= ($_GET['fromlevel'] != "")?"`level` >= ? and ":""; # $query .= ($_GET['tolevel'] != "")?"`level` <= ? and ":""; # # if($_GET['alive'] == 1) { // Check alive players # $query .= "`id` NOT IN (SELECT playerdead_ID FROM medical_ward) "; # } This would give me the following error Fatal error: Call to a member function on a non-object in /home/caraudi/public_html/CAC_Mafia_Test_Site/battle.php on line 382 Line 382 is $bool = 1; $query = $db->execute($query, $values); //Search! if ($query->recordcount() > 0) //Check if any players were found { $bool = 1; while ($result = $query->fetchrow()) { echo "<tr class=\"row" . $bool . "\">\n"; echo "<td width=\"25%\"><a href=\"profile.php?username=" . $result['username'] . "\">" . $result['username'] . "</a></td>\n"; echo "<td width=\"10%\">" . $result['level'] . "</td>\n"; echo "<td width=\"28%\">" . $result['City_Name'] ."</td>\n"; echo "<td width=\"37%\"><a href=\"battle.php?act=attack&username=" . $result['username'] . "\">Attack</a></td>\n"; echo "</tr>\n"; $bool = ($bool==1)?2:1; } } anyone have any idea on how to make it work the way I need it too? Thanks, Link to comment https://forums.phpfreaks.com/topic/118031-need-help-with-search-script-adodb/ Share on other sites More sharing options...
genericnumber1 Posted August 4, 2008 Share Posted August 4, 2008 Not going into detail, you're getting that error because your query is not formatted properly. I don't deal with third party scripts, but if it's within your ability, add or die(mysql_error()) after your script's query() function (where it would say mysql_query() or mysqli_query() etc.) Alternatively, if you can't find the area to add that, try putting echo mysql_error(); underneath $db->execute(). This may not work if the db class is set up in such a way as to limit the function's use outside of the class (eg. if it open/closes connection on a per-query basis). Link to comment https://forums.phpfreaks.com/topic/118031-need-help-with-search-script-adodb/#findComment-607216 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.