Jump to content

MySQLi Unknown column 'playerID' in 'where clause'


Firestorm3d

Recommended Posts

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();
}

 

 

Link to comment
Share on other sites

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

 

 

Link to comment
Share on other sites

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);

Link to comment
Share on other sites

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?

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.