Код (Text): $str = "SELECT users.viewer_id AS attacker,names.name,names.all_sh,battles.status,battles.good_before,battles.bad_before,battles.good_after,battles.bad_after,battles.dgold FROM battles JOIN last_battles JOIN users JOIN names WHERE (battles.id = last_battles.b1 OR battles.id = last_battles.b2 OR battles.id = last_battles.b3 OR battles.id = last_battles.b4 OR battles.id = last_battles.b5 OR battles.id = last_battles.b6 OR battles.id = last_battles.b7 OR battles.id = last_battles.b8 OR battles.id = last_battles.b9 OR battles.id = last_battles.b10 OR battles.id = last_battles.b11 OR battles.id = last_battles.b12 OR battles.id = last_battles.b13 OR battles.id = last_battles.b14 OR battles.id = last_battles.b15 OR battles.id = last_battles.b16 OR battles.id = last_battles.b17 OR battles.id = last_battles.b18 OR battles.id = last_battles.b19 OR battles.id = last_battles.b20 ) AND battles.attacker = names.id AND battles.attacker = users.id AND last_battles.id = $id "; $req = mysql_query($str, $db); if (!$req) exit ("req=false&error=mysql_error&s=1"); $xml = "<xml>"; while ($row = mysql_fetch_assoc($req)) { $xml .= "\n\t<battle>"; $xml .= "\n\t\t<status>".$row["status"]."</status>"; $xml .= "\n\t\t<your>"; $xml .= "\n\t\t\t<units>".($row["bad_before"] - $row["bad_after"])."</units>"; $xml .= "\n\t\t\t<gold>".$row["dgold"]."</gold>"; $xml .= "\n\t\t</your>"; $xml .= "\n\t\t<target>"; $xml .= "\n\t\t\t<id>".$row["attacker"]."</id>"; $xml .= "\n\t\t\t<name>".$row["name"]."</name>"; $xml .= "\n\t\t\t<all>".$row["all_sh"]."</all>"; $xml .= "\n\t\t\t<units>".($row["good_before"]-$row["good_after"])."</units>"; $xml .= "\n\t\t\t<gold>0</gold>"; $xml .= "\n\t\t\t<diamond>0</diamond>"; $xml .= "\n\t\t</target>"; $xml .= "\n\t</battle>"; } Имеется такой код, однако, некоторым игрокам не приходит этот xml. Во флеше все правильно, мб что-то тут не так, подскажите
Запрос у тебя фейлится/приходит пустым. От того XML не формируется/формируется пустым. От того не приходит клиенту.
Если if (!$req) пиши в лог (журнал событий) файл причину ошибки mysql и sql запрос из $str. И где проверка mysql num rows? Чтобы знать что ко-во результатов больше нуля.
В приведенном фрагменте кода нет генерации </xml>. Есть вероятность, что над этим фрагментом выше еще какое-то условие, которое не срабатывает.
Код (PHP): <? include ("updUser.php"); include ("balance.php"); define ("SIZE_OF_SMALLINT", 65535); $id=intval($_POST['id']); if ($id==0){ $id = intval($_POST['viewer_id']); $s = "(SELECT id FROM users WHERE viewer_id = $id)"; }else $s = "$id"; $auth_key=$_POST['hash']; if ($auth_key != h($id)) exit("req=false&error=auth_error"); updUser($s); $str = " SELECT names.id, names.name, names.all_sh, buildings.palace, buildings.farm, buildings.tower, buildings.secret, last_battle.time AS battle_time, resources.gold, resources.dgold, resources.millet, resources.dmillet, resources.diamond, resources.ruby, (SELECT course FROM course ORDER BY id DESC LIMIT 1 ) AS ruby_course, units.sh_num, units.sh_atk, units.sh_hp, units.sh_acc, units.bw_num, units.bw_atk, units.bw_hp, units.bw_acc, units.sp_num, units.sp_atk, units.sp_hp, units.sp_acc, units.auras, relax_time.time AS relax_time, in_battle.battle_id, tasks.task, tasks.premium, tasks.premium_start, tasks.premium_time, hero.atk as hero_atk, hero.hp as hero_hp, hero.hero_atk as hero_hero_atk, hero.gold as hero_gold, hero.exp as hero_exp, hero.level as hero_level, hero.full_exp as hero_full_exp FROM names JOIN buildings JOIN last_battle JOIN resources JOIN units JOIN relax_time JOIN last_online JOIN in_battle JOIN tasks JOIN hero WHERE names.id = buildings.id AND names.id = last_battle.id AND names.id = last_online.id AND names.id = resources.id AND names.id = units.id AND names.id = relax_time.id AND names.id = in_battle.id AND names.id = tasks.id AND names.id = hero.id AND names.id = $s "; $req = mysql_query($str, $db); if (!$req) exit("req=false&error=mysql_error&p=0&s=3"); if (mysql_num_rows($req) == 0) exit("req=false&error=no_village&s=4"); $arr = mysql_fetch_array($req); $id = $arr["id"]; if ($arr["battle_id"] != 0) { //Надо добавить информацию о противнике } $nool = 50; $arr["relax_time"] = $arr["relax_time"] - time(); if ($arr["relax_time"] < 0) $arr["relax_time"] = 0; $arr["hash"] = md5("_".$arr["palace"]); $arr["time_now"] = time(); $_time = time(); $arr["time_day" ] = mktime(0,0,0); $arr["_sh_atk"] = DEFAULT_SH_ATK; $arr["_sh_hp"] = DEFAULT_SH_HP; $arr["_sh_acc"] = DEFAULT_SH_ACC; $arr["_bw_atk"] = DEFAULT_BW_ATK; $arr["_bw_hp"] = DEFAULT_BW_HP; $arr["_bw_acc"] = DEFAULT_BW_ACC; $arr["_sp_atk"] = DEFAULT_SP_ATK; $arr["_sp_hp"] = DEFAULT_SP_HP; $arr["_sp_acc"] = DEFAULT_SP_ACC; $arr["_tower_atk"] = DEFAULT_TOWER_ATK; $arr["_hero_atk"] = DEFAULT_HERO_ATK; $controllSummPre = "_".$arr["_sh_atk"].$arr["_sh_hp"].$arr["_sh_acc"].$arr["_bw_atk"].$arr["_bw_hp"].$arr["_bw_acc"].$arr["_sp_atk"].$arr["_sp_hp"].$arr["_sp_acc"].$arr["_tower_atk"].$arr["_hero_atk"]; $arr["hash2"] = md5($controllSummPre); $arr["auth_key"] = h($arr["id"]); $arr["ruby_cost"] = RUBY_COST; $s = ""; foreach ($arr as $key => $value){ $s .= "&$key=$value"; } $str = "UPDATE last_online SET time=".time()." WHERE id=".$arr["id"]; $req = mysql_query($str, $db); if (!$req) exit("req=false&error=mysql_error&p=1"); $str12 = "SELECT users.viewer_id AS attacker,names.name,names.all_sh,battles.status,battles.good_before,battles.bad_before,battles.good_after,battles.bad_after,battles.dgold FROM battles JOIN last_battles JOIN users JOIN names WHERE (battles.id = last_battles.b1 OR battles.id = last_battles.b2 OR battles.id = last_battles.b3 OR battles.id = last_battles.b4 OR battles.id = last_battles.b5 OR battles.id = last_battles.b6 OR battles.id = last_battles.b7 OR battles.id = last_battles.b8 OR battles.id = last_battles.b9 OR battles.id = last_battles.b10 OR battles.id = last_battles.b11 OR battles.id = last_battles.b12 OR battles.id = last_battles.b13 OR battles.id = last_battles.b14 OR battles.id = last_battles.b15 OR battles.id = last_battles.b16 OR battles.id = last_battles.b17 OR battles.id = last_battles.b18 OR battles.id = last_battles.b19 OR battles.id = last_battles.b20 ) AND battles.attacker = names.id AND battles.attacker = users.id AND last_battles.id = $id "; $req = mysql_query($str12, $db); if (!$req) exit ("req=false&error=mysql_error&s=1"); $xml = "<xml>"; while ($row = mysql_fetch_assoc($req)) { $xml .= "\n\t<battle>"; $xml .= "\n\t\t<status>".$row["status"]."</status>"; $xml .= "\n\t\t<your>"; $xml .= "\n\t\t\t<units>".($row["bad_before"] - $row["bad_after"])."</units>"; $xml .= "\n\t\t\t<gold>".$row["dgold"]."</gold>"; $xml .= "\n\t\t</your>"; $xml .= "\n\t\t<target>"; $xml .= "\n\t\t\t<id>".$row["attacker"]."</id>"; $xml .= "\n\t\t\t<name>".$row["name"]."</name>"; $xml .= "\n\t\t\t<all>".$row["all_sh"]."</all>"; $xml .= "\n\t\t\t<units>".($row["good_before"]-$row["good_after"])."</units>"; $xml .= "\n\t\t\t<gold>0</gold>"; $xml .= "\n\t\t\t<diamond>0</diamond>"; $xml .= "\n\t\t</target>"; $xml .= "\n\t</battle>"; } $xml .= "\n</xml>"; if ($xml != "<xml>\n</xml>"){ $str = " UPDATE last_battles SET b1 = 0, b2 = 0, b3 = 0, b4 = 0, b5 = 0, b6 = 0, b7 = 0, b8 = 0, b9 = 0, b10 = 0, b11 = 0, b12 = 0, b13 = 0, b14 = 0, b15 = 0, b16 = 0, b17 = 0, b18 = 0, b19 = 0, b20 = 0 WHERE id = $id "; $req = mysql_query($str, $db); if (!$req) exit ("req=false&error=mysql_error&s=2"); } echo "req=true".$s."&xml=$xml".($arr["time_now"] - $arr["premium_start"]); ?> Вот весь код
Ну..что я могу сказать, должно быть как минимум <xml></xml>, а не просто </xml>. И да, кроме прочего xml формируется не валидный.
Код (Text): if ($xml != "<xml>\n123</xml>"){ $str = " UPDATE last_battles SET b1 = 0, b2 = 0, b3 = 0, b4 = 0, b5 = 0, b6 = 0, b7 = 0, b8 = 0, b9 = 0, b10 = 0, b11 = 0, b12 = 0, b13 = 0, b14 = 0, b15 = 0, b16 = 0, b17 = 0, b18 = 0, b19 = 0, b20 = 0 WHERE id = $id "; $req = mysql_query($str, $db); if (!$req) exit ("req=false&error=mysql_error&s=2"); } Если вот так, то все отлично