I’ve got a php page grabbing news storys from a csv file. Yes, I know I could/should use a database addition like MySQL, but i’m not using it.
[code=php] $handle = fopen(‘data/news.csv’, ‘r’);
$newsline = “0”;
if ($newsnum == “”)
{
$newsnum = “5”;
}
if ($loggedinyn == “1”)
{
$data = (fgetcsv($handle, 0, ‘,’));
while ($newsline != $newsnum && $data[0] != FALSE)
{
echo “*****”;
echo $data[0];
echo “*****”;
echo $data[1];
$data = (fgetcsv($handle, 0, ‘,’));
$newsline = $newsline + 1;
}
}
fclose($handle);
$loggedinyn is set to 1 when the user logs in.
If they’ve logged in, then $newsnum is set by their preferences to the number of news stories to show.
$newsline is set to zero, and added to every time it goes through the while loop.
Last, the two parts where it says echo “*****”; I had a rather long amount of text in them, so in the interest of fitting everything into this post, I omitted it.
Ok, so no problems, it works. Why am I posting? Well, when I tryed changing “$handle = fopen(‘data/news.csv’, ‘r’);” from read mode (r) to read+write (r+) it told me:
[quote]
Warning: fopen(data/news.csv) [function.fopen]: failed to open stream: Permission denied in C:Documents and Settings****My Documentsweb server*
Warning: fgetcsv() expects parameter 1 to be resource, boolean given in C:Documents and Settings****My Documentsweb server*
Warning: fclose(): supplied argument is not a valid stream resource in C:Documents and Settings****My Documentsweb server*
So that’s not quite what I was looking for…. Any ideas what I did wrong?