Просмотр поста

.
ДоХтор
# _Казимир_ (04.05.2014 / 08:42)
Просмотрите пожалуйста, допущены ли в написании парсера ошибки?
<?php
define('_IN_JOHNCMS', 1);

$headmod = 'smanager';
$textl = 'PARSER';
require_once ("../incfiles/core.php");
require_once ("
Я тебе вписал ошибки в комментарии, исправляй сам

<?php
 define('_IN_JOHNCMS', 1);

 $headmod = 'smanager';
 $textl = 'PARSER';
 require_once ("../incfiles/core.php");
 require_once ("../incfiles/head.php");


 $file = file_get_contents('http://www.sports.ru/milan/?type=team');
 preg_match('/<div class="stat mB15">(.*?)<\/div>/is', $file, $info);

 preg_match_all("/<tr>\n<td>(.*?)<\/td>/is", $info['1'], $num);
 preg_match_all("/<td [^\d] >\n<i class=\"flag-s flag-[\d] \" title=\"(.*?)\"/is", $info['1'], $nat);//1.пустой массив
 preg_match_all("/<a style=\"name\" href=\"\/tags\/[\d] .html\">(.*?)<\/a>/is", $info['1'], $name);//2.пустой массив
 preg_match_all("/<td title=\"(.*?)\">(.*?)<\/td>/is", $info['1'], $pos);
 preg_match_all("/<\/td>\n<td>(.*?)<\/td>\n<td>(.*?)<\/td>\n<td>(.*?)<\/td>/is", $info['1'], $inf);

 for ($i = 0; $i < count($num['1']); $i /*3.бесконечный цикл! вместо $i надо $i++*/) {
 $file = file_get_contents('http://www.sports.ru/milan/?type=team');//4.лишняя строка(дублирует стр.25)

 if ($file) {
 mysql_query("INSERT INTO `m_team` SET
 `id` = ''.$i.'',
 `team` = '1',
 `name` = ''.$name[1].'',
 `flag` = ''.$nat[1].'',
 `nomer` = ''.$num[1].'',
 `pos` = ''.$pos[1].''
 "); //5.$name[1],$nat[1],$num[1],$pos[1] - это массивы!
     //для записи в БД их надо сериализовать
 echo 'Пост '.$i.' - Готово!<br/>';
 } else {
 echo 'Пост '.$i.' - Eror!<br/>';
 }

 }

 echo '</div>';
 require_once ("../incfiles/end.php");

 ?>