$sql = mysql_query("SELECT `guid`, `race`, `name`, `level`, `gender`, `playerBytes`, `playerBytes2` FROM `characters` WHERE `name` = '".mysql_real_escape_string($charname)."' LIMIT 1");
$result = mysql_fetch_array($sql);
if (mysql_num_rows($sql)=='0') {
die ("Character not found!");
}
$name = $result['name'];
$level = $result['level'];
$player_guid = $result['guid'];
$b = $result['playerBytes'];
$b2 = $result['playerBytes2'];
$ha = ($b>>16)%256;
$hc = ($b>>24)%256;
$fa = ($b>>8)%256;
$sk = $b%256;
$fh = $b2%256;
$queryinv = mysql_query("SELECT * FROM `character222_inventory` WHERE `guid` = '".mysql_real_escape_string($player_guid)."'");
$queryres = mysql_fetch_array($queryinv);
$slot = $queryres['slot'];
$guid = $queryres['guid'];
// maybe will work
$r1 = mysql_query("SELECT * FROM `character222_inventory` WHERE `slot` = '0' AND `bag` = '".$definebag."' AND `guid` = '".mysql_real_escape_string($player_guid)."' LIMIT 1");
$re1 = mysql_fetch_assoc($r1);
$item_head1 = $re1['item_template'];
$r2 = mysql_query("SELECT * FROM `character222_inventory` WHERE `slot` = '1' AND `bag` = '".$definebag."' AND `guid` = '".mysql_real_escape_string($player_guid)."' LIMIT 1");
$re2 = mysql_fetch_assoc($r2);
$item_neck1 = $re2['item_template'];
$r3 = mysql_query("SELECT * FROM `character222_inventory` WHERE `slot` = '2' AND `bag` = '".$definebag."' AND `guid` = '".mysql_real_escape_string($player_guid)."' LIMIT 1");
$re3 = mysql_fetch_assoc($r3);
$item_shoulder1 = $re3['item_template'];
$r4 = mysql_query("SELECT * FROM `character222_inventory` WHERE `slot` = '3' AND `bag` = '".$definebag."' AND `guid` = '".mysql_real_escape_string($player_guid)."' LIMIT 1");
$re4 = mysql_fetch_array($r4);
$item_shirt1 = $re4['item_template'];
$r5 = mysql_query("SELECT * FROM `character222_inventory` WHERE `slot` = '4' AND `bag` = '".$definebag."' AND `guid` = '".mysql_real_escape_string($player_guid)."' LIMIT 1");
$re5 = mysql_fetch_array($r5);
$item_chest1 = $re5['item_template'];
$r6 = mysql_query("SELECT * FROM `character222_inventory` WHERE `slot` = '5' AND `bag` = '".$definebag."' AND `guid` = '".mysql_real_escape_string($player_guid)."' LIMIT 1");
$re6 = mysql_fetch_array($r6);
$item_belt1 = $re6['item_template'];
$r7 = mysql_query("SELECT * FROM `character222_inventory` WHERE `slot` = '6' AND `bag` = '".$definebag."' AND `guid` = '".mysql_real_escape_string($player_guid)."' LIMIT 1");
$re7 = mysql_fetch_array($r7);
$item_legs1 = $re7['item_template'];
$r8 = mysql_query("SELECT * FROM `character222_inventory` WHERE `slot` = '7' AND `bag` = '".$definebag."' AND `guid` = '".mysql_real_escape_string($player_guid)."' LIMIT 1");
$re8 = mysql_fetch_array($r8);
$item_feet1 = $re8['item_template'];
$r9 = mysql_query("SELECT * FROM `character222_inventory` WHERE `slot` = '8' AND `bag` = '".$definebag."' AND `guid` = '".mysql_real_escape_string($player_guid)."' LIMIT 1");
$re9 = mysql_fetch_array($r9);
$item_wrist1 = $re9['item_template'];
$r10 = mysql_query("SELECT * FROM `character222_inventory` WHERE `slot` = '9' AND `bag` = '".$definebag."' AND `guid` = '".mysql_real_escape_string($player_guid)."' LIMIT 1");
$re10 = mysql_fetch_array($r10);
$item_gloves1 = $re10['item_template'];
$r11 = mysql_query("SELECT * FROM `character222_inventory` WHERE `slot` = '10' AND `bag` = '".$definebag."' AND `guid` = '".mysql_real_escape_string($player_guid)."' LIMIT 1");
$re11 = mysql_fetch_array($r11);
$item_finger1 = $re11['item_template'];
$r12 = mysql_query("SELECT * FROM `character222_inventory` WHERE `slot` = '11' AND `bag` = '".$definebag."' AND `guid` = '".mysql_real_escape_string($player_guid)."' LIMIT 1");
$re12 = mysql_fetch_array($r12);
$item_finger2 = $re12['item_template'];
$r13 = mysql_query("SELECT * FROM `character222_inventory` WHERE `slot` = '12' AND `bag` = '".$definebag."' AND `guid` = '".mysql_real_escape_string($player_guid)."' LIMIT 1");
$re13 = mysql_fetch_array($r13);
$item_trinket1 = $re13['item_template'];
$r14 = mysql_query("SELECT * FROM `character222_inventory` WHERE `slot` = '13' AND `bag` = '".$definebag."' AND `guid` = '".mysql_real_escape_string($player_guid)."' LIMIT 1");
$re14 = mysql_fetch_array($r14);
$item_trinket2 = $re14['item_template'];
$r15 = mysql_query("SELECT * FROM `character222_inventory` WHERE `slot` = '14' AND `bag` = '".$definebag."' AND `guid` = '".mysql_real_escape_string($player_guid)."' LIMIT 1");
$re15 = mysql_fetch_array($r15);
$item_back1 = $re15['item_template'];
$r16 = mysql_query("SELECT * FROM `character222_inventory` WHERE `slot` = '15' AND `bag` = '".$definebag."' AND `guid` = '".mysql_real_escape_string($player_guid)."' LIMIT 1");
$re16 = mysql_fetch_array($r16);
$item_main_hand1 = $re16['item_template'];
$r17 = mysql_query("SELECT * FROM `character222_inventory` WHERE `slot` = '16' AND `bag` = '".$definebag."' AND `guid` = '".mysql_real_escape_string($player_guid)."' LIMIT 1");
$re17 = mysql_fetch_array($r17);
$item_off_hand1 = $re17['item_template'];
$r18 = mysql_query("SELECT * FROM `character222_inventory` WHERE `slot` = '17' AND `bag` = '".$definebag."' AND `guid` = '".mysql_real_escape_string($player_guid)."' LIMIT 1");
$re18 = mysql_fetch_array($r18);
$item_ranged_slot1 = $re18['item_template'];
function wowhead_did($item) {
global $config;
mysql_select_db($config['world_db']);
$sql = mysql_query("SELECT displayid FROM item_template WHERE entry = '".$item."'");