Skrypt artykułów na strone www na plikach

Mam prosty skrypt dodawania artykułów na strone www na plikach txt i gdy dziś chciałem sobie dodać drugi artykuł nie spodziewanie wyrzuciło mi błąd na mojej stronie:

Notice: Undefined offset: 87 in /home/users/history/public_html/skrypt.php on line 15


Notice: Undefined offset: 88 in /home/users/history/public_html/skrypt.php on line 15


Notice: Undefined offset: 89 in /home/users/history/public_html/skrypt.php on line 15


Notice: Undefined offset: 90 in /home/users/history/public_html/skrypt.php on line 15


Notice: Undefined offset: 91 in /home/users/history/public_html/skrypt.php on line 15


Notice: Undefined offset: 92 in /home/users/history/public_html/skrypt.php on line 15


Notice: Undefined offset: 93 in /home/users/history/public_html/skrypt.php on line 15


Notice: Undefined offset: 94 in /home/users/history/public_html/skrypt.php on line 15


Notice: Undefined offset: 95 in /home/users/history/public_html/skrypt.php on line 15


Notice: Undefined offset: 96 in /home/users/history/public_html/skrypt.php on line 15


Notice: Undefined offset: 97 in /home/users/history/public_html/skrypt.php on line 15


Notice: Undefined offset: 98 in /home/users/history/public_html/skrypt.php on line 15


Notice: Undefined offset: 99 in /home/users/history/public_html/skrypt.php on line 15


Notice: Undefined offset: 100 in /home/users/history/public_html/skrypt.php on line 15


Notice: Undefined offset: 101 in /home/users/history/public_html/skrypt.php on line 15


Notice: Undefined offset: 102 in /home/users/history/public_html/skrypt.php on line 15


Notice: Undefined offset: 103 in /home/users/history/public_html/skrypt.php on line 15


Notice: Undefined offset: 104 in /home/users/history/public_html/skrypt.php on line 15


Notice: Undefined offset: 105 in /home/users/history/public_html/skrypt.php on line 15


Notice: Undefined offset: 106 in /home/users/history/public_html/skrypt.php on line 15


Notice: Undefined offset: 107 in /home/users/history/public_html/skrypt.php on line 15


Notice: Undefined offset: 108 in /home/users/history/public_html/skrypt.php on line 15


Notice: Undefined offset: 109 in /home/users/history/public_html/skrypt.php on line 15


Notice: Undefined offset: 110 in /home/users/history/public_html/skrypt.php on line 15


Notice: Undefined offset: 111 in /home/users/history/public_html/skrypt.php on line 15

Jak mój atykuł drugi kończy się na słowie " strony www" to jest dobrze, ale jak już dodam kolejne zdania do artykułu to wyrzuca mi powyższy błąd :frowning:

Może ktoś mi z tym pomóC ? Adres mojej strony to: www.history.is.net.pl

Co nam po linku do twojej strony ? Daj kod newsów.

o to kod newsow:

Plik skrypt.php

<?php

error_reporting(E_ALL);

$template = 'plik.txt';

$fd = fopen($template,"r");

$message = @fread($fd, filesize($template));


$piece=explode("$$$",$message);


function cut_comment($str,$ile) {

$count = str_word_count($str);

if ($count >$ile) {

$body = explode(" ", $str);

$str = $body['0']." ";

for ($n=1; $n < $ile; $n++) {

$str .= $body[$n]." ";

}

$str .= "...
";

}

else {

$str = $str;

}

return $str;

}


$skroc = 112;

$ile = count ($piece);


for ( $i = 0; $i < $ile-1; $i++){

echo cut_comment($piece[$i],$skroc)."więcej.. 
";

}


fclose($fd); 


?>[/code]


Plik news.php

[code]<?php $comments=0; $file = file(‘comments/’.$_GET[‘id’].‘.txt’); rsort($file); $file = file(‘comments/’.$_GET[‘id’].‘.txt’); $file = array_reverse($file); foreach($file as $key => $value) { $comments++; } ?> <?php session_start(); $template = ‘plik.txt’; $fd = fopen($template,„r”); $message = @fread($fd, filesize($template)); $piece=explode(„$$$”,$message); $id=$_GET[‘id’]; echo $piece[$id]; ?>
Pokaż komentarze (<?=$comments?>) ↓                          Skomentuj ten wpis ↓

<? include(„pokaz.php”); ?>

<? if($_GET[‘wyslano’]==1) echo ‘Skomentowałeś już tego newsa’; else include(„dodaj.php”); ?>

Czy Może ktoś mi pomóc ? Jeszcze mam plik o nazwie plik.txt gdzie zapisuje moje wszystkie artykuły na stronie

Pokazuje komunikat(y)

Notice: Undefined offset: 87 in /home/users/history/public_html/skrypt.php on line 15

Niezdefinowany indeks 87 w skrypt.php w linii 15, czyli…

$str .= $body[$n]." ";

… ponieważ $body[87] wzwyż nie istnieje. Tak więc należy to zwarunkować

if( isset($body[$n]) ) $str .= $body[$n]." ";

i powinno latać.

http://translate.google.pl/

ra-v dzieki serdeczne, działa mi dobrze dzięki Tobie.

A nie lepiej zrobić system newsów z tabli sql ? A nie z pliku? Według mnie w sql są większe i prostsze możliwości edycji newsa.