Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Naruszenie zasad ochrony pamieci?
pietrekk
post
Post #1





Grupa: Zarejestrowani
Postów: 6
Pomógł: 0
Dołączył: 11.09.2009

Ostrzeżenie: (0%)
-----


Witam,

Mam skrypt, ktory wykorzystuje rekurencje i czasem wywala taki blad na konsoli: "Naruszenie zasad ochrony pamieci".
Ktos wie w czym moze tkwic problem albo jak to mozna sprawdzic?

i druga kwestia czy jest jakies rozwiazanie, ktore jesli dzialanie skryptu zostaje przerwane wywoluje inna funkcje/plik ?

Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
pietrekk
post
Post #2





Grupa: Zarejestrowani
Postów: 6
Pomógł: 0
Dołączył: 11.09.2009

Ostrzeżenie: (0%)
-----


to jest taki spider/crawler do np robienia sitemap'y, zrobilem to z wykorzystaniem mysql:

function crawl($domain)
{
//select url not crawled yet
$sql = "SELECT * FROM tmpUrlCrawled WHERE visited IS NULL LIMIT 1";
$result = mysql_query($sql) or die (mysql_error()."<br>Query: $sql");
if(mysql_num_rows($result)>0)
{
$url = mysql_result($result,0,"url");
$url = mysql_real_escape_string($url);
//update url which was crawled
$sql = "UPDATE tmpUrlCrawled set visited = 'y' WHERE url = '$url'";
$result = mysql_query($sql) or die (mysql_error()."<br>Query: $sql");
//crawl links
if(preg_match("/^http[s]?:\/\/[^\/]*".str_replace('.', '\.', $domain)."/i", $url))
{
$tmpLinks = getUrls($url);
$tmpLinks = array_unique($tmpLinks);
}
//add crawled links to DB
if($tmpLinks)
foreach ($tmpLinks as $tmpLink)
{
$tmpLink = mysql_real_escape_string($tmpLink);
$sql = "INSERT IGNORE INTO tmpUrlCrawled set url = '$tmpLink'";
$result = mysql_query($sql) or die (mysql_error()."<br>Query: $sql");
}
//rekurencja
crawl($domain);
}

}
Powód edycji: [thek]: Proszę oBBCode, bo czyta się to źle każdemu...
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 27.12.2025 - 16:58