there are many XML Files of type http://namastebet.com/betradar/NAMASTEBET2016-6-4T09-14-57.XML
They have a parameter like Competitors and have the names of two teams of rivals. How can I implement their addition to the database? here's how I am doing but fails:
<head> <title>Test</title> </head> <? ////////// $db = mysql_connect("localhost","logn","pass"); mysql_select_db("BD",$db) or die(mysql_error()); mysql_set_charset(utf8); ////////// $conn_id = ftp_connect("Host"); $login_result = ftp_login($conn_id, "login", "123456"); $contents = ftp_nlist($conn_id, "."); $counts=count($contents); for($i=5;$i<=$counts;$i++) { //echo $contents[$i].'<br>'; $xml=new SimpleXMLElement("betradar/$contents[$i]",null,true); foreach($xml->Sports->Sport as $Sport) { $SportName = $Sport->Texts->Text->Value; foreach($Sport->Category as $Cat) { $CatName = $Cat->Texts->Text->Value; foreach($Cat->Tournament as $Tournament) { $TourName = $Tournament->Texts->Text->Value; foreach($Tournament->Match as $Cat2) { $MatchID = $Cat2[BetradarMatchID]; foreach($Cat2->Fixture->Competitors->Texts as $Cat3) { $players = $Cat3->Text->Text->Value; } foreach($Cat2->Fixture->Competitors as $Players) { $Player1 = $Players->Player1->Text->Value; $Player2 = $Players->Player2->Text->Value; $Player3 = $Players->Player3->Text->Value; $Player4 = $Players->Player4->Text->Value; } foreach($Cat2->Fixture as $Match) { $CupRound = $Match->RoundInfo->Cupround; $MatchDate = $Match->DateInfo->MatchDate; } } } foreach($Cat->Outright as $CatA) { $OutRightID = $CatA['BetradarOutrightID']; $EventName = $CatA->Fixture->EventInfo->EventName->Texts->Text->Value; foreach($CatA->Fixture->Competitors->Texts as $Players2) { $OutRightPlayers = $Players2->Text->Text->Value; } } } $CheckMatch = mysql_query("SELECT * FROM Betradar WHERE MatchID='".$MatchID."'"); $CheckMatchNum = mysql_num_rows($CheckMatch); if($CheckMatchNum > 0) { //$Up = mysql_query("UPDATE Betradar SET Team2='".$players."', OutT2='".$OutRightPlayers."' WHERE MatchID='".$MatchID."'"); } else { $Add = mysql_query("INSERT INTO Betradar(`SportName`,`CatName`,`TourName`,`MatchID`,`OutRightID`,`Team1`,`Team2`,`TPlayer1`,`TPlayer2`,`TPlayer3`,`TPlayer4`,`CupRound`,`MatchDate`,`EventName`,`OutT1`,`OutT2`,`FileN`) VALUES('".$SportName."','".$CatName."','".$TourName."','".$MatchID."','".$OutRightID."','".$players."','".$players."','".$Player1."','".$Player2."','".$Player3."','".$Player4."','".$CupRound."','".$MatchDate."','".$EventName."','".$OutRightPlayers."','".$OutRightPlayers."','".$contents[$i]."')") or die(mysql_error()); if($add == true) { echo 'ok'; } else { echo 'bed'; } } } } ?>