Hi again.
I am making my own layout, as I was suggested to before, and it's going great. I'm learing more than I could ever have done before, and the pride of doing it by myself is tremendous. *I'm a big boy now!*
Okay, but like every time I post here, I have a problem. I'm using a little script to pull a text file out of a lower directory, based on the post variables I get. Unfortunately, it's really not working.
Here's my code:
<?php
$article = $_POST['articles'];
if ( $article == "\" ) {
echo \"The article you were looking for was not found.\";
} else {
echo \"The if statement evaluated to false\";
include(\"/articles/\".$article\".txt\");
}
?>I'm getting this error:
Quote: Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in c:\appserv\www\abyss\pages\viewarticle.php on line 9
'Line 9' refers to my 'include' line.
Can you tell me why this isn't working? Also, can you find me a solution to my crafty users who plays with the POST variables and hits a wrong/invalid article (to a text file that doesn't exist)?
Thanks.
~Max
Webmaster! 





timjpriebe posted this at 15:15 — 1st May 2006.
He has: 2,666 posts
Joined: Dec 2004
Not sure if this is the only thing, but you forgot a period
include("/articles/".$article".txt");
should be
include("/articles/".$article.".txt");
Tim
http://www.tandswebdesign.com
Maxwell posted this at 17:09 — 1st May 2006.
He has: 52 posts
Joined: Apr 2006
Works beautifully. Thanks.
Greg K posted this at 19:29 — 1st May 2006.
He has: 1,676 posts
Joined: Nov 2003
I would recommend also doing a check with file_exists before including it as well.
See http://us2.php.net/manual/en/function.file-exists.php for more info.
-Greg
[This space intentionally left blank]
Cool Geek Supplies: www.ThinkGeek.com
Maxwell posted this at 19:30 — 1st May 2006.
He has: 52 posts
Joined: Apr 2006
Yes, after some researching, I have come to use that function, as well. Thank you.