There is an array of links. You need to add them to the database, but first check out the report file.

public function query_page() { $data_link = array( "/orsk/doma_dachi_kottedzhi/dom_60_m_na_uchastke_5_sot._577934693", "/orsk/doma_dachi_kottedzhi/dom_130_m_na_uchastke_6_sot._754499329", "/orsk/doma_dachi_kottedzhi/kottedzh_295_m_na_uchastke_7_sot._553062836", "/orsk/doma_dachi_kottedzhi/dom_40.1_m_na_uchastke_3_sot._767494601", "/orsk/doma_dachi_kottedzhi/dom_54_m_na_uchastke_10_sot._783057977", ); $i=0; foreach ($data_link as $advert){ if ($i == 5) break; $inspection = $this->inspection($advert); //тут проверяем из файла-отчета if ($inspection) $this->error = true; else $this->error = false; if (!$this->error) { $mas_save["link"] = $advert; $db_query = forming_db_query_indexmas("db_advert", $mas_save, "new", "id_advert"); $q_ident = obr_db_query($db_query); //пишем в базу } $i++; sleep(9); } } private function inspection($link) { $result = false; $text_inspection = file_get_contents("result.txt"); $text_inspection = explode("\n", $text_inspection); //получаем массив ссылок из файла отчета if (sizeof($text_inspection) > 0) { foreach ($text_inspection as $get_link){ if ($get_link == $link) { $result = true; break; } } } return $result; } 

At the moment I have already in the report file the first 3 links from the array. The last 2 must be added, but not added. I get an error with the database. I have to sleep for up to 5 seconds and everything works fine. Tell me, what's the problem?

  • 1. What is the base error? 2. If this code is copy-paste from the source code, then the query_page method lacks one curly bracket that would close the method body. 3. Why is there sleep() at all? .. - lolbas
  • about the bracket - just forgot to add here .. It is .. But the error with the base is not detailed .. He writes that it is just a mistake with the base. Sleep, because the links are parted in this method. I just showed it off the shelf - Sarkis Allahverdian
  • What do you have in obr_db_query? - Nikola Tesla
  • show create table on the table to which the insert goes, please - strangeqargo
  • you need to see the contents of the forming_db_query_indexmas and obr_db_query methods ... try removing /orsk/doma_dachi_kottedzhi/dom_40.1_m_na_uchastke_3_sot._767494601 this one ... then 4s will be added instead of 3x? - Lesiuk Alexey

0