Options
PHP Help...
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.
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.
0
Comments
$p=$p . ".txt";
needs to be:
$p="$_GET . '.txt'";
Or something close to that.
NS
thank you so much dude.
-kev