S
ShockingAlberto
Guest
ok, for a site i'm amking a nice news script.
i'm fairly new to php, but from a book i've been learning it well, the only thinbg i have problems with are the loops which allways confuse me.
the display part of my news script isn't working, due to those horrid parse errors. but i cant find anything to cause a parse error...
i'm getting errors on line 9, and if i remove that line i get them it on line10(basically the same thing).
if you notice the script itself is wrong, dont tell me, i need to learn myself, it's just that i cant see why i'm getting parse errors on these 2 lines.
the function is designed to go in a table, so ignore the html parts, cus it makes sense.
here's what the script does:
it reads from a opens the file, and should get the contents, and put them into an array. since the newst news is added at the end of the file, it will print the 2 parts of the array(and thus 2 lines from the file)first, and hopefully the loop will make it go down the file printing each news header and then the actual news.
i have a feeling i've messed up for for loop, but i dont mind, i just wanna know what's wrong on lines 9 and 10, where it should take right pparts from the array, into the string.
since there's no basic mistakes there, i guessi need to re-read about arrays or soemthing, but if someone could [point out what's wrong with those lines it would really help
i'm fairly new to php, but from a book i've been learning it well, the only thinbg i have problems with are the loops which allways confuse me.
the display part of my news script isn't working, due to those horrid parse errors. but i cant find anything to cause a parse error...
i'm getting errors on line 9, and if i remove that line i get them it on line10(basically the same thing).
Code:
<?php
function readnews(){
$newsfile="news.txt";
$open=fopen($newsfile, "r");
if($open){
$data = file($newsfile);
for ($n=count($data); $n>0;$n-2){
$m = $n-1
$getheader=$data[$m]; //this is line 9 fyi
$getnews=$data[$n]; //and this is line 10, basically the same ting
print("
<tr><td width=\"580\" height=\"15\" bgcolor=\"#CE5A1D\">$getheader</td></tr><tr><td width=\"580\">$getnews</td></tr>
");
}
fclose($open)
print("<hr>
/n");
}else{
print("Error reading from news file!");
}
}
?>
the function is designed to go in a table, so ignore the html parts, cus it makes sense.
here's what the script does:
it reads from a opens the file, and should get the contents, and put them into an array. since the newst news is added at the end of the file, it will print the 2 parts of the array(and thus 2 lines from the file)first, and hopefully the loop will make it go down the file printing each news header and then the actual news.
i have a feeling i've messed up for for loop, but i dont mind, i just wanna know what's wrong on lines 9 and 10, where it should take right pparts from the array, into the string.
since there's no basic mistakes there, i guessi need to re-read about arrays or soemthing, but if someone could [point out what's wrong with those lines it would really help