Ok, I've got this sort of working, here's what I have so far:
$hostname = "xxx";
$username = "xxx";
$password = "xxx";
$dbName = "xxx";
$i = 1;
$count = 10;
while ($i < $count) {
$data = file_get_contents('http://$site?player_id=' . $i);
if (!ereg("(does not currently exist)", $data)) {
preg_match("/<p class=\'playername\'> (.*) <span/Uis", $data, $playername);
preg_match("/<span class=\'playerposition\'> #(.*)<\/span>/Uis", $data, $numpos);
$numpos2 = explode(" ", $numpos[1]);
preg_match("/<b>DOB:<\/b> (.*)<\/td><\/tr>/Uis", $data, $dob);
preg_match("/<b>Place of Birth:<\/b> (.*)<\/td><\/tr>/Uis", $data, $pob);
preg_match("/<b>HT:<\/b> (.*) <b>/Uis", $data, $height);
preg_match("/<b>WT:<\/b> (.*)<\/td>/Uis", $data, $weight);
preg_match("/<b>Shoots: <\/b>(.*)<\/td>/Uis", $data, $shoots);
preg_match("/Drafted by (.*)\.<\/td>/Uis", $data, $drafted);
MYSQL_CONNECT($hostname,$username,$password) OR DIE("can't connect to database");
@mysql_select_db($dbName) or die("can't select database");
$query = "INSERT INTO players (name,no,pos,dob,pob,height,weight,shoots,drafted) VALUES ('$playername[1]','$numpos2[0]','$numpos2[1]','$dob[1]','$pob[1]','$height[1]','$weight[1]','$shoots[1]','$drafted[1]');";
MYSQL_QUERY($query);
MYSQL_CLOSE();
}
$i++;
}
The problem is, when I run it I frequenlty get the following error and I can only run through 5-10 player IDs or else I will get this error all the time:
Fatal error: Maximum execution time of 30 seconds exceeded in xxx.php on line 13
How can I keep this script from timing out all the time?
TIA.