File Locking prevents a file from being written to by 2+ programs simultaneously.
When program A places a lock on a file, program B has to wait until A removes the lock, until it can write.
PHP will patiently wait until the lock on the file is removed before writing to it.
$newXML = $_GET['newXML'];
$newXML = stripslashes($newXML);
$file = fopen("scores.xml", "w");
if(!is_writable($file)) die("File not readable"); //uh oh
if(flock($file,LOCK_EX) ){ //exclusive lock - for writing
fwrite ($file, "$newXML");
}//if file not locked successfully, nothing will be written.
flock($file,LOCK_UN);
fclose($file);
print ("Written: $newXML");
?>
Garth Farley