grafillo!
01.01.2015, 22:33
Столкнулся с проблемой которую не могу никак решить, передаю из флеша в php xml
function SendBotsUser(){
var vars:URLVariables = new URLVariables();
vars['type']=['add_bots'];
vars['xml']='<xml><bot login="BOT2" select_room="гогого" id_unreg_user="">SharaBot</bot></xml>';
var requestmes:URLRequest = new URLRequest;
requestmes.url = "http://troll_ch/bots.php";
requestmes.method = URLRequestMethod.POST;
requestmes.data = vars;
sendToURL(requestmes);
}
и не могу никак его распарсить в php, знатоки php помогите с парсингом
function pars_xml () {
$servertime = time();
$req = $_POST['xml'];
//mysql_query("INSERT INTO tb_room SET Login='$req',Time='$servertime',user_type='unregistered',Room='$select_room' ");
//$req = '<xml><bot login="BOT2" select_room="гогого" id_unreg_user="">SharaBot</bot></xml>';
$xml = new SimpleXmlIterator ($req);
foreach ($xml as $bot)
{
$select_room = $bot['select_room'];
$login = $bot['login'];
mysql_query("INSERT INTO tb_room SET Login='$bot',Time='$servertime',user_type='unregistered',Room='$select_room' ");
}
}
Самый прикол в том что если есть атрибуты, то оно не парсится, без атрибутов всё работает нормально, также всё передаётся, если просто вставить строку в таблицу то вставляет норм xml который я передавал. Есть знатоки php помогите плиз?
function SendBotsUser(){
var vars:URLVariables = new URLVariables();
vars['type']=['add_bots'];
vars['xml']='<xml><bot login="BOT2" select_room="гогого" id_unreg_user="">SharaBot</bot></xml>';
var requestmes:URLRequest = new URLRequest;
requestmes.url = "http://troll_ch/bots.php";
requestmes.method = URLRequestMethod.POST;
requestmes.data = vars;
sendToURL(requestmes);
}
и не могу никак его распарсить в php, знатоки php помогите с парсингом
function pars_xml () {
$servertime = time();
$req = $_POST['xml'];
//mysql_query("INSERT INTO tb_room SET Login='$req',Time='$servertime',user_type='unregistered',Room='$select_room' ");
//$req = '<xml><bot login="BOT2" select_room="гогого" id_unreg_user="">SharaBot</bot></xml>';
$xml = new SimpleXmlIterator ($req);
foreach ($xml as $bot)
{
$select_room = $bot['select_room'];
$login = $bot['login'];
mysql_query("INSERT INTO tb_room SET Login='$bot',Time='$servertime',user_type='unregistered',Room='$select_room' ");
}
}
Самый прикол в том что если есть атрибуты, то оно не парсится, без атрибутов всё работает нормально, также всё передаётся, если просто вставить строку в таблицу то вставляет норм xml который я передавал. Есть знатоки php помогите плиз?