Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

newb help again (include) 1

Status
Not open for further replies.

unborn

Programmer
Joined
Jun 26, 2002
Messages
362
Location
US
error:
Warning: main(/home/error-pr/public_html/test/news/0001.txt ) [function.main]: failed to create stream: No such file or directory in /home/error-pr/public_html/test/news/news.php on line 19

Warning: main() [function.main]: Failed opening '/home/error-pr/public_html/test/news/0001.txt ' for inclusion (include_path='') in /home/error-pr/public_html/test/news/news.php on line 19




code:
<?
$posts = file(&quot;config.txt&quot;);
$postcount = count($posts);
$postinfo = explode(&quot;:&quot;,$posts[0]);
$pages = $postinfo[1];
$totalposts = $postinfo[0];
echo &quot;posts: $postcount\n Per Page:$pages\n Total: $totalposts\n&quot;;

if ($postcount==0) echo &quot;No news is available!&quot;;
else
{
if (empty($startcount))
{
for($i=1; $i < $pages + 1; $i++)
{
if (!empty($posts[$i]))
{
$include_path = &quot;/home/error-pr/public_html/test/news/$posts[$i]&quot;;
include $include_path; echo &quot;<br><br>&quot;;
}
else
{
exit;
}
}

$startcount = pages+1;
echo &quot;<form action=news.php method=post>
<input type=hidden name=startcount value=$startcount>
<input type=hidden name=endcount value=$startcount+$pages>
<input type=submit value=next>&quot;;
}
else
{
for($i=$startcount; $i < $endcount + 1; $i++)
{
if (!empty($posts[$i]))
{
include &quot;DOCUMENT_ROOT/test/news/$posts[$i]&quot;; echo &quot;<br><br>&quot;;
}
else
{
exit;
}
}
echo &quot;<form action=news.php method=post>
<input type=hidden name=startcount value=$endcount>
<input type=hidden name=endcount value=$endcount+$pages>
<input type=submit value=next>&quot;;
}
}
?>



i know its not perfect im jsut starting and im attempting to make a news thing that doesnt use a database.. the config.txt is a simple file formated like so..

10:5
0001.txt
0002.txt
0003.txt

and so on...

from the file it reads that there are 10 posts.. and it wants 5 posts on each page... then it will read the txt files (news posts) down the line..

i really dont want any other one.. im really trying to learn to use the code and stuff but im so fustrated right now.. i know the whole code may not look nice right now .. im just tryign to get the effin posts to POST :D thanks for the help




im still messin with it o.0


in the begining man created code.
in the end code will create man.
clones are coming only matter of time.
examples?
 
btw... the only reason i put include_path thing is because it has it in the rror so though i had to.. but didint work... the info in it use to be right in include... -stresses out.

in the begining man created code.
in the end code will create man.
clones are coming only matter of time.
examples?
 
I recommend against your manipulating the include_path variable the way you are.

include_path is where PHP looks for the files you tell it to open when it cannot find them where you tell it.

You don't put filenames in include_path, and you don't issue the include function against directories.

Want the best answers? Ask the best questions: TANSTAAFL!
 
ok ya i just read some more info and realized when it is talking about include path they are meanign in the ini .... but it gives the same error even when i dont touch the include path .. here what im using now.




<?
$posts = file(&quot;config.txt&quot;);
$postcount = count($posts);
$postinfo = explode(&quot;:&quot;,$posts[0]);
$pages = $postinfo[1];
$totalposts = $postinfo[0];
include_path = &quot;../home/error-pr/public_html/test/news/&quot;;
echo &quot;posts: $postcount <br> page: $pages <br> total: $totalposts <br><br>&quot;;

if ($postcount==0) echo &quot;No news is available!&quot;;
else
{
if (empty($startcount))
{
for($i=1; $i < $pages + 1; $i++)
{
if (!empty($posts[$i]))
{
//&quot;/home/error-pr/public_html/test/news/$posts[$i]&quot;
include $posts[$i];//echo &quot;<br><br>&quot;;
}
else
{
exit;
}
}

$startcount = pages+1;
echo &quot;<form action=news.php method=post>
<input type=hidden name=startcount value=$startcount>
<input type=hidden name=endcount value=$startcount+$pages>
<input type=submit value=next>&quot;;
}
else
{
for($i=$startcount; $i < $endcount + 1; $i++)
{
if (!empty($posts[$i]))
{
//include &quot;DOCUMENT_ROOT/test/news/$posts[$i]&quot;; echo &quot;<br><br>&quot;;
}
else
{
exit;
}
}
echo &quot;<form action=news.php method=post>
<input type=hidden name=startcount value=$endcount>
<input type=hidden name=endcount value=$endcount+$pages>
<input type=submit value=next>&quot;;
}
}
?>




when i do include &quot;0001.txt&quot; outside of the for i loop it works... in the foor i loop it says it cant find file 0001.txt in the directory where it is located... i checked the permissions and i should have permission.. bleh any help?


in the begining man created code.
in the end code will create man.
clones are coming only matter of time.
examples?
 
It's because when you read the file with [tt]file[/tt] the ending linefeeds and carriage returns are at the end of each filename. You would have to [tt]trim[/tt] it first for the [tt]include[/tt] to work..

//Daniel
 
omg tytytytytytytyty!

in the begining man created code.
in the end code will create man.
clones are coming only matter of time.
examples?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top