发送INIT_DB数据包时出错。 PID = 7060

时间:2012-01-04 17:57:30

标签: php exception web-crawler

当执行以下函数时,我抛出了一个异常,之后我收到了这个错误:

  

发送INIT_DB数据包时出错。 PID = 7060

然后脚本发出了几个警告:

  

mysql_fetch_row()期望参数1为资源

功能:

private function initiateChildCrawler($parent_Url_Html) {

        global $CFG;
        static $foundLink;
        static $parentID;
        static $urlToCrawl_InstanceOfChildren;

        $foundLinkArray = array();
        $tempHtml = $parent_Url_Html->getHTML();
        $foundLinkCount = 0;
        foreach($tempHtml->find('a') as $foundLinkArray[$foundLinkCount++]);

        $anotherArray = array();
        $x = 0;     
        for($i = 0; $i<$foundLinkCount; $i++) {
            $anotherArray[$x++] = $foundLinkArray[$i]->href;            
        }

        foreach($anotherArray as $foundLink) 
        {
            $foundLink = url_to_absolute($parent_Url_Html->getURL(), $foundLink);

            if($this->validateEduDomain($foundLink)) 
            {
                $parentID = $this->loadSaveInstance->parentExists_In_URL_DB_CRAWL($this->returnParentDomain($foundLink));
                if($parentID != FALSE) 
                {
                    if($this->loadSaveInstance->checkUrlDuplication_In_URL_DB_CRAWL($foundLink) == FALSE)
                    {
                        $urlToCrawl_InstanceOfChildren = new urlToCrawl($foundLink);
                        if($urlToCrawl_InstanceOfChildren->getSimpleDomSource($CFG->finalContext)!= FALSE)
                        {                           
                            try {
                                $this->loadSaveInstance->url_db_html($urlToCrawl_InstanceOfChildren->getURL(), $urlToCrawl_InstanceOfChildren->getHTML());
                                $this->loadSaveInstance->saveCrawled_To_URL_DB_CRAWL(NULL, $foundLink, "crawled", $parentID);
                            } catch (DbException $e) {
                                echo "<br><br>Exception Catched on line 303!!!<br><br>";
                                echo "The link where the exception was thrown was: {$foundLink}<br>";
                                if(strstr($e->getMessage(), 'MySQL server has gone away')) {
                                    $this->connection = mysql_connect("localhost", "root", "");
                                    mysql_select_db("crawler1", $this->connection);
                                }                               
                            }                                               
                        }
                    }
                }
            }
        }   
    }

导致异常的特定网址是:http://www.ashford.edu/student_services/deanslist.htm

我对此毫无头绪。请帮忙。

0 个答案:

没有答案