diff --git a/index.php b/index.php index e9ff64803..45ece68cb 100644 --- a/index.php +++ b/index.php @@ -1,6 +1,6 @@ query_assoc($query); - return $result['id']; + if ($result) { + return $result['id']; + } + else { + return null; + } } function getZoneIDByName($short_name) { @@ -184,7 +189,12 @@ function get_zone_by_npcid($npcid) { $query = "SELECT short_name FROM zone WHERE zoneidnumber=\"$npczone\""; $result = $mysql->query_assoc($query); - return $result['short_name']; + if ($result) { + return $result['short_name']; + } + else { + return null; + } } function get_zoneid_by_npcid($npcid) { @@ -193,7 +203,13 @@ function get_zoneid_by_npcid($npcid) { $query = "SELECT id FROM zone WHERE zoneidnumber=\"$npczone\""; $result = $mysql->query_assoc($query); - return $result['id']; + + if ($result) { + return $result['id']; + } + else { + return null; + } } function get_npcid_by_emoteid($emoteid) { diff --git a/lib/headbars.php b/lib/headbars.php index bff6dafd0..1af21cd9c 100644 --- a/lib/headbars.php +++ b/lib/headbars.php @@ -389,11 +389,13 @@ function npcs() { $version = 0; $zid = "___"; $results = array(); + $zonename = ""; if($npc_list == '') $npc_list = 1; if($z) { + $zonename = $z; $zid = getZoneID($z) . "___"; $query = "SELECT version FROM zone WHERE id = \"$zoneid\""; $result = $mysql->query_assoc($query); @@ -402,11 +404,11 @@ function npcs() { if($npc_list == 1) { if ($version > 0) { - $query = "SELECT id, name FROM npc_types WHERE id like \"$zid\" AND version = $version GROUP BY id ORDER BY name ASC"; + $query = "SELECT npc_types.id AS id, npc_types.name AS name FROM npc_types JOIN spawnentry ON id = spawnentry.npcID JOIN spawn2 ON spawnentry.spawngroupID = spawn2.spawngroupID WHERE spawn2.zone = '$zonename' AND spawn2.version = $version GROUP BY id ORDER BY name ASC"; $results = $mysql->query_mult_assoc($query); } if ($version < 1) { - $query = "SELECT id, name FROM npc_types WHERE id like \"$zid\" GROUP BY id ORDER BY name ASC"; + $query = "SELECT npc_types.id AS id, npc_types.name AS name FROM npc_types JOIN spawnentry ON id = spawnentry.npcID JOIN spawn2 ON spawnentry.spawngroupID = spawn2.spawngroupID WHERE spawn2.zone = '$zonename' AND spawn2.version = 0 ORDER BY name ASC"; $results = $mysql->query_mult_assoc($query); } } diff --git a/lib/npc.php b/lib/npc.php index c5eee8f95..a21890fb3 100644 --- a/lib/npc.php +++ b/lib/npc.php @@ -961,10 +961,10 @@ function npc_info() { function get_ispet() { global $mysql, $npcid; - $query = "SELECT count(*) FROM pets WHERE npcID=$npcid"; + $query = "SELECT count(*) AS count FROM pets WHERE npcID=$npcid"; $result = $mysql->query_assoc($query); - return $result['count(*)']; + return $result['count']; } function get_pet() {