In the preperation step if a node do not have inbound links
$Sql = "select pagerank.master, tmp_pr.nroout from pagerank inner join tmp_pr on (tmp_pr.id = pagerank.master) where pagerank.slave = ".$row['id'];
do not return any value.
$formula is updated according to the result of the above query so it is empty.
all the rows in tmp_pr whose formula value is empty are selected in a loop and so this process is never ends