0

Hi,

I’ll use a txt file to store locations in it. When I user click on button, the locations will be read from txt file and stored in an array. If more than 1 user run this script, will it cause problem like “File is already open”? It this reliable.

Thanks

<?php
$myFile ='locations.txt';
$myArray = file ($myFile);
 
foreach($myArray as &$value) {
	insert into a combobox = trim($value);
}
unset($value);
?>
2
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by veledrom
0

No that shouldn't cause such a problem, just remember the rules when working with files:

1. Only give users access to files that you want them to have access to. Use permissions to restrict read/write/execute on files. I would suggest making sure that users can only read your location file except in very rare circumstances, and never let them delete it.
and 2. Don't forget to close the file handle when you are finished with it. Bad things happen when you don't clean up after yourself.

0

Hi,
Thanks for your answers. According to your answers, also;

1. When first PHP page is loaded, it only populates info into combo. There is nothing to do with users. Therefore, this should be safe enough. Is this right?
2. Do i need to add anything else to close or clean things after? If yes please state. I'll be happy.

Thanks

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.