Forum Moderators: coopster
<?php
$progdatabase = '/var/www/data/programs.data';
if(!file_exists($progdatabase))
die("Database doesn't exist");
if(!is_readable($progdatabase))
die("Database not readable");
if(!is_writable($progdatabase))
die("Database not writable");
$fp = fopen($progdatabase, "r") or die("Couldn't open file");
$data = fread($fp, filesize($fp));
while(!feof($fp)) {
$data .= fgets($fp, 1024);
}
fclose($fp);
?> I keep getting these error messages!
Warning: filesize(): Stat failed for Resource id #2 (errno=2 - No such file or directory) in /var/www/list.php on line 29
Warning: fread(): Length parameter must be greater than 0. in /var/www/list.php on line 29 I know there is text within the text file too! ggraajj.. The folder data & the file programs.data I KNOW are chmod 777. I just have no clue...
$progdatabase = 'datae/list.data';
if(!file_exists($progdatabase))
die("Database doesn't exist");
if(!is_readable($progdatabase))
die("Database not readable");
if(!is_writable($progdatabase))
die("Database not writable");
readfile($progdatabase); That's weird...but still, it doesn't give me the text of the file, it just outputs it onto the page :(
hmm, looking at the code again
$fp = fopen($progdatabase, "r") or die("Couldn't open file");
$data = fread($fp, filesize($fp));
while(!feof($fp)) {
$data .= fgets($fp, 1024);
}
what is the fread line for? You can use the fgets loop by itself to get the data. Why not just this?
$fp = fopen($progdatabase, "r") or die("Couldn't open file");
while(!feof($fp)) {
$data .= fgets($fp, 1024);
}