Forum Moderators: coopster
When I do:
$filename = "../".$_GET['cat'].".dba";
$categories = fopen($filename, "r") or die("Can't Open File $filename");
$cat_file = fread($categories, filesize($filename));
fclose($categories);
I get
Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 1095 bytes) in /#*$!xxx/xxxxx/viewlist.php on line 38
Help!
Thanks,
Rob
$cat = $_GET['cat'];
if (strpos($cat, '.')!== false ¦¦ strpos($cat, '/')!== false ¦¦ strpos($cat, '\')!== false) {
die('bad cat');
}
Second, if you want to deal with the lines of a text file one at a time, you could use the
file()function. This will read the entire file and return it as an array, with the value of each array element corresponding to a line in the file.
$lines = file($filename);
Lastly, if you want to import data from large database type files (.dba), have a look at the Database (dbm-style) Abstraction Layer Functions chapter in the PHP manual.