
Originally Posted by
diabolo
and what happens if an error happens midway, and it drops the table, wouldn't you lose all the time/hard work?
The error code was copied from your code.
Combining the two methods and removing the inner loop,
Code:
$leftover = $numChances % 10 ;
$byTen = $numChances - $leftover ;
for ( $i=0; $i + 10 < $byTen ; $i = $i + 10 ) {
$sql = "INSERT INTO $table (chanceID) VALUES (NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL)";
mysql_query($sql);
}
# code to do $leftover more entries
Another idea is to lock the table before the inserts and then unlock it afterwards.