PDA

View Full Version : PHP Help...


kevin
14 Jun 2003, 2:00am
Okay....I am trying to write a content displayer thing....it would have a text filename passsed to it (minus the .txt) and then it would output the text file.
Example: www.....com/blah.php?p=suck would output suck.txt

Only problem is htat it doesnt. It has to be something i am doing horribly stupid, because it works if I manually declare $p to a text file name...

<html>
<head><title>php shizzy</title></head>
<?php
$p=$p . ".txt";
if (!file_exists($p)) {
echo "Couldn't find file...";
}
else {
$newfile = fopen($p,"r");
$content = fread($newfile, filesize($p));
fclose($newfile);
}
$content = stripslashes($content);
$content = htmlentities($content);
$content = nl2br($content);
echo $content;
?>
</body>
</html>
Any ideas? Sorry for being so ubernewb.

Enverex
14 Jun 2003, 3:18am
I believe

$p=$p . ".txt";

needs to be:

$p="$_GET['p'] . '.txt'";

Or something close to that.

NS

kevin
14 Jun 2003, 3:26am
minus the <<">>'s around the $_GET...txt' and it worked beautifully.
thank you so much dude.
-kev