Options

PHP Help...

edited June 2003 in Science & Tech
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...

[php]<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>[/php]
Any ideas? Sorry for being so ubernewb.

Comments

  • EnverexEnverex Worcester, UK Icrontian
    edited June 2003
    I believe

    $p=$p . ".txt";

    needs to be:

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

    Or something close to that.

    NS
  • edited June 2003
    minus the <<">>'s around the $_GET...txt' and it worked beautifully.
    thank you so much dude.
    -kev
Sign In or Register to comment.