Firestorm3d Posted June 19, 2008 Share Posted June 19, 2008 so i'm having an issue with my search function. it was working the other day but now it doesn't seem to be working. i did change stuff but nothing in the select functions. heres the code. function search($sort, $table, $start, $finish, $search, $searchtable){ global $con; connect(); switch($searchtable){ case "playerID": $search1 = intval($search, 10); $select = "SELECT * FROM player WHERE playerID = '$search1' ORDER BY $table.$sort ASC LIMIT $start, $finish"; case "guildTag": $select = "SELECT * FROM player WHERE $searchtable LIKE CONVERT( _utf8 '$search' USING latin1 ) ORDER BY $table.$sort ASC"; case "name": $select = "SELECT * FROM player WHERE $searchtable LIKE CONVERT( _utf8 '$search' USING latin1 ) ORDER BY $table.$sort ASC"; case "location": $select = "SELECT * FROM base WHERE $searchtable LIKE CONVERT( _utf8 '$search%' USING latin1 ) ORDER BY $table.$sort ASC"; } $result = mysqli_query($con, $select) or die(mysqli_error($con)); while($players = mysqli_fetch_array($result)){ $playerID = $players["playerID"]; $select2 = "SELECT * FROM base WHERE ownerID=$playerID"; $result2 = mysqli_query($con, $select2); /*if($filter == "nog"){ if($players["guildTag"] == NULL){ continue; } }*/ for($i = 0;$i <= $count;$i++ && $guild = NULL){ $bases = mysqli_fetch_array($result2); $count = count($bases); if($players["guildTag"] == NULL){ $guild = "None"; } echo "<tr><th>".$guild.$players["guildTag"]."</th><th>".$players["name"]."</th><th>".$players["playerID"]."</th><th>".'<a href="http://ceti.astroempires.com/map.aspx?loc='.$bases["location"].'"target="_blank">'.$bases["location"].'</a>'."</th><th>".$bases["economyCur"]."</th><th>/</th><th>".$bases["economy"]."</th><th>".$bases["commandCenters"]."</th><th>".$bases["planetaryRing"]."</th><th>".$bases["stamp"]."</th></tr>"; } } mysqli_free_result($result) && mysqli_free_result($result2); closecon(); } Quote Link to comment https://forums.phpfreaks.com/topic/110971-mysqli-unknown-column-playerid-in-where-clause/ Share on other sites More sharing options...
rhodesa Posted June 19, 2008 Share Posted June 19, 2008 um...silly question, but are you SURE you have a column called playerID in the player table?? Quote Link to comment https://forums.phpfreaks.com/topic/110971-mysqli-unknown-column-playerid-in-where-clause/#findComment-569341 Share on other sites More sharing options...
Firestorm3d Posted June 20, 2008 Author Share Posted June 20, 2008 no questions are silly but let me show the table structure data.player.playerID data.player.name data.player.guildID data.player.guildTag data.player.guildTitle data.player.bases data.player.fleets data.player.level data.player.economy data.player.fleetSize data.player.technology data.player.experience data.player.experienceCur data.player.techEnergy data.player.techComputer data.player.techArmour data.player.techLaser data.player.techMissiles data.player.techStellarDrive data.player.techPlasma data.player.techWarpDrive data.player.techShielding data.player.techIon data.player.techPhoton data.player.techArtificialIntelligence data.player.techDisruptor data.player.techCybernetics data.player.stamp data.player.player data.player.ip data.player.sernum Quote Link to comment https://forums.phpfreaks.com/topic/110971-mysqli-unknown-column-playerid-in-where-clause/#findComment-570001 Share on other sites More sharing options...
rhodesa Posted June 20, 2008 Share Posted June 20, 2008 I assume this line is throwing the error: $result = mysqli_query($con, $select) or die(mysqli_error($con)); what is the value of $select at this point? you can use this to see it: $result = mysqli_query($con, $select) or die('MySQL Error: '.mysqli_error($con).' for SQL: '.$select); Quote Link to comment https://forums.phpfreaks.com/topic/110971-mysqli-unknown-column-playerid-in-where-clause/#findComment-570068 Share on other sites More sharing options...
Firestorm3d Posted June 20, 2008 Author Share Posted June 20, 2008 i found the issue it is the switch($searchtable){ case "playerID": $select = "SELECT * FROM player WHERE $searchtable = '$search1' ORDER BY $table.$sort ASC LIMIT $start, $finish"; case "guildTag": $select = "SELECT * FROM player WHERE $searchtable LIKE CONVERT( _utf8 '$search' USING latin1 ) ORDER BY $table.$sort ASC"; case "name": $select = "SELECT * FROM player WHERE $searchtable LIKE CONVERT( _utf8 '$search' USING latin1 ) ORDER BY $table.$sort ASC"; case "location": // ----> $select = "SELECT * FROM base WHERE $searchtable LIKE CONVERT( _utf8 '$search%' USING latin1 ) ORDER BY $table.$sort ASC"; for some reason this switch wants to default to location no matter what the $searchtable variable. Is that because I don't have a default? Quote Link to comment https://forums.phpfreaks.com/topic/110971-mysqli-unknown-column-playerid-in-where-clause/#findComment-570598 Share on other sites More sharing options...
PFMaBiSmAd Posted June 20, 2008 Share Posted June 20, 2008 Re-read the switch section in the php manual. Each case: needs a break; statement. Quote Link to comment https://forums.phpfreaks.com/topic/110971-mysqli-unknown-column-playerid-in-where-clause/#findComment-570603 Share on other sites More sharing options...
Firestorm3d Posted June 20, 2008 Author Share Posted June 20, 2008 unfortunately that breaks the function too. it works fine without break and i am going to reassemble the function in incorporate more options. Quote Link to comment https://forums.phpfreaks.com/topic/110971-mysqli-unknown-column-playerid-in-where-clause/#findComment-570615 Share on other sites More sharing options...
Firestorm3d Posted June 20, 2008 Author Share Posted June 20, 2008 ok i entered in break 1; so that it only breaks the switch Quote Link to comment https://forums.phpfreaks.com/topic/110971-mysqli-unknown-column-playerid-in-where-clause/#findComment-570617 Share on other sites More sharing options...
PFMaBiSmAd Posted June 20, 2008 Share Posted June 20, 2008 Then there is something wrong with where or how you put them in. Quote Link to comment https://forums.phpfreaks.com/topic/110971-mysqli-unknown-column-playerid-in-where-clause/#findComment-570633 Share on other sites More sharing options...
fenway Posted June 22, 2008 Share Posted June 22, 2008 This is degerating into a purely php issue -- and it's about to be moved. Quote Link to comment https://forums.phpfreaks.com/topic/110971-mysqli-unknown-column-playerid-in-where-clause/#findComment-571665 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.