开发者

Fscanf stops after 130 lines PHP

开发者 https://www.devze.com 2023-03-17 04:15 出处:网络
I have been working on this for days, I thought I had it but was wrong. $done=0; $filename = \"raw_urls.txt\";

I have been working on this for days, I thought I had it but was wrong.

    $done=0;
    $filename = "raw_urls.txt";
    if(! ($fhandle = fopen($filename, "r")))
    { echo "File failed to open"; 
         Exit; }
    while((fscanf($fhandle, "%s\n",$url_full))!== false)
     {     
       print (mysql_error());

     if(strlen($url_full) > 3)
     {
        $url_stat++;
        $end_st = strlen($url_full)-29;
        $s_url= substr($url_full,29,$end_st);
        }
     else{
         $done++;
         }

     $res1开发者_JAVA技巧=sql("SELECT * FROM `spy3` WHERE `Landingpage` LIKE '%$s_url%' LIMIT 0, 30 ",$o);
     if($row=mysql_fetch_array($res1))
        {
         $lp=$row[6];
         $found++;  
        }
       else{
        $nfound++;
        }


sql("insert into sitemap (url, stat_url,nf, s_recno) 
values (
'$url_full',
'$lp',
'$nfound',
'$url_stat'
)", $o);
print (mysql_error());
$found=0;
$nfound=0;
}

?>

I have tried fgets, changed txt files, it always stops between 128 and 132 lines of text. There are 2500 lines in the text file. Php.ini memory is very big. If I cut the txt file where it stops and save it, its 9k big.


have seen this link..?

Please Click here

OR

you can also use fseek($handle, 0); AND refer this link

Thanks.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号