To reply on Icrontic, register now.

It only takes 30 seconds.

Have an account? Sign in for less ads.

Forgot?
kevin
Guest

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 Code:
<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($newfilefilesize($p));
    
fclose($newfile);
    }
    
$content stripslashes($content);
    
$content htmlentities($content);
    
$content nl2br($content);
    echo 
$content;
?>
</body>
</html>
Any ideas? Sorry for being so ubernewb.
Enverex
~-+-~
Enverex
5,852 Posts
I believe

$p=$p . ".txt";

needs to be:

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

Or something close to that.

NS
__________________ RetroTracks - Classic Computer and Game Music
kevin
Guest
minus the <<">>'s around the $_GET...txt' and it worked beautifully.
thank you so much dude.
-kev
Go Back   Icrontic Forums > Tech: Software > General Software
Jump to
This Thread Search this Thread
Search this Thread:

Advanced Search


Current time: 1:37am (GMT)
Powered by vBulletin®
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Get Vanilla instead. Trust me.