How to solve this timeout problem?

Discussion in 'PHP' started by hhheng, Nov 14, 2007.

  1. #1
    I developed the script to update the PR values for the urls in my database, and the output the old and new pr value of the urls. But the output will always stop at around #500, however, I have more than 1000 urls in my database.

    Can anybody check the script for me and give me a solution?

    $prupdate = new pageRank(); //pageRank() is the class for updating pr.
    $count = 1;
    $total = 0;
    $qry = mysql_query("SELECT id, url, pr FROM sub_dirs WHERE status = 1");
    while($result = mysql_fetch_array($qry))
    {
    $id = $result['id'];
    $url = $result['url'];
    $oldpr = $result['pr'];
    $newpr = $prupdate->printrank($url);
    if(!$newpr) $newpr = 0;
    $pr_diff = $newpr - $oldpr;
    $total = $total + $pr_diff;
    if(mysql_query("UPDATE sub_dirs SET pr = ".$newpr." WHERE id = ".$id.""))
    {
    //Outputing the new and old pr for comparison
    if($count%2 == 0) echo "<tr bgcolor=\"#D7E1FF\">";
    else echo "<tr>";
    echo "<td width=\"50\"><div align=\"center\">" .$count. "</div></td>";
    echo "<td width=\"300\"><a href=\"http://" .$url. "\" target=\"_blank\">" .$url. "</td>";
    echo "<td width=\"100\" class=\"oldpr\"><div align=\"center\">" .$oldpr. "</div></td>";
    echo "<td width=\"100\" class=\"newpr\"><div align=\"center\">" .$newpr. "</div></td>";
    echo "<td width=\"100\" class=\"pr_diff\"><div align=\"center\">" .$pr_diff. "</div></td>";
    echo "</tr>";
    }
    else
    {
    if($count%2 == 0) echo "<tr bgcolor=\"#D7E1FF\">";
    else echo "<tr>";
    echo "<td width=\"50\"><div align=\"center\">" .$count. "</div></td>";
    echo "<td width=\"300\"><a href=\"http://" .$url. "\" target=\"_blank\">" .$url. "</td>";
    echo "<td width=\"300\" colspan=\"3\" class=\"pr_diff\"><div align=\"center\">Errors while updating PR</div></td>";
    echo "</tr>";
    }
    $count++;
     
    hhheng, Nov 14, 2007 IP
  2. ngcoders

    ngcoders Active Member

    Messages:
    206
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    55
    #2
    Put
    set_time_limit (0);
    before line 1
     
    ngcoders, Nov 14, 2007 IP