0

Below is my code, it is a script I need to run just 1 time to update a new mysql table I have added, I have 60,000 users and it ran and added 268 rows, it did not show any errors or anything, it just didnt add the rest and I have no idea why?

    <?PHP
require_once "../config/functions.inc.php";

// get users
$sql = 'SELECT * FROM  friend_login';
$result = executequery($sql);   
while($row = mysql_fetch_assoc($result)){
    // get states
    $sql = 'SELECT * FROM  usstates order by rand() limit 1';
    $state = getSingleResult($sql);
    //convert to lat and long
    $geo = get_geo($state);
    $lat = $geo['Latitude'];
    $long = $geo['Longitude'];

    //insert lat/long into locations table
    $insert = "INSERT INTO friend_location (user_id, lat, `long`) VALUES ('$row[auto_id]', '$lat', '$long')";
    executeQuery($insert);

    echo 'user updated with ' .$state. ' <BR> userID=' .$row[auto_id]. ' <BR><BR><BR>';
}
?>
3
  • Did you check your error log? Commented Jul 24, 2009 at 20:48
  • this may some crazy but I am new to working on a home server using xampp, I really don't even know where the error log would be located Commented Jul 24, 2009 at 20:50
  • Hmm not sure about xampp... maybe ask about it on serverfault :) Commented Jul 24, 2009 at 21:06

1 Answer 1

6

try setting the maximum script execution time to 0 (infinite):

ini_set('max_execution_time', 0);

If you have display_errors or error_reporting turned off, then you may not see a fatal error generated by a timeout.

Sign up to request clarification or add additional context in comments.

5 Comments

I just tried this, so far so good, its been running for about 5 minutes and has updates about 1k of 60k. This is gonna take a while, maybe I shouldn't have made it output to the browser, my browser will probably crash
That's verrrry slow but if this is just a one-off there's not any point optimizing your code
For the record though: ORDER BY RAND() is slow, doing a query every time around the loop is slow, and inserting individual rows instead of in batches is slow :)
yes it is! 30 minutes later now and it's only 1/6th done lol I never knew something like this would timeout so fast though, the timeout time must be much smaller on my home server then my production server
Or use the equivalent set_time_limit(0)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.