What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Skype & Technology » Tech Talk » Php Help

Php Help
Author: Message:
Stigmata
Veteran Member
*****



Posts: 3520
Reputation: 45
20 / Other / Flag
Joined: Jul 2003
O.P. Php Help
well its for a tutorial section. each tutorial is a txt file in a far far away folder.
first someone will will choose a language, and then they select a page/tutorial.

i have this so far
[code]
<?php
$page = htmlentities($_GET['page']) ;
$language = htmlentities($_GET['lan']) ;
if (!isset($_GET['page'])) {
if(!isset($_GET['lan'])) {
include ("pages/code/home.txt");
}
else {
include ("pages/code/$language.txt");
}
}
else {
include("pages/code/$language/$page.txt");
}
?>

now i want to create a sorta error page, if the file cannot be found, then it echos "page cannot be found"

thanks for the help :)
01-22-2005 10:18 AM
Profile PM Web Find Quote Report
-dt-
Scripting Contest Winner
*****

Avatar
;o

Posts: 1819
Reputation: 74
35 / Male / Flag
Joined: Mar 2004
RE: Php Help
you just use file_exists

http://au.php.net/manual/en/function.file-exists.php

so you could use
code:
$file = "path to file here";
if (!file_exists($file)) {
die("page can not be found");
}

just put it before anything echo's in your code and when the file can not be found it will echo "page can not be found" then kill the script

so in your script it would be something like

code:

<?php
$page = htmlentities($_GET['page']) ;
$language = htmlentities($_GET['lan']) ;
if (!isset($_GET['page'])) {
if(!isset($_GET['lan'])) {
include ("pages/code/home.txt");
}
else {
$file = "pages/code/$language.txt";
if (!file_exists($file)) { die("page can not be found");}

include ("$file");

}
}
else {
$file = "pages/code/$language/$page.txt";
if (!file_exists($file)) { die("page can not be found");}

include ("$file");
}
?>

[/code]

This post was edited on 01-22-2005 at 10:32 AM by -dt-.
[Image: dt2.0v2.png]      Happy Birthday, WDZ
01-22-2005 10:25 AM
Profile PM Web Find Quote Report
Stigmata
Veteran Member
*****



Posts: 3520
Reputation: 45
20 / Other / Flag
Joined: Jul 2003
O.P. RE: Php Help
thnx works like a charm :)
01-22-2005 10:31 AM
Profile PM Web Find Quote Report
-dt-
Scripting Contest Winner
*****

Avatar
;o

Posts: 1819
Reputation: 74
35 / Male / Flag
Joined: Mar 2004
RE: Php Help
quote:
Originally posted by Stigmata
thnx works like a charm :)

lol i just updated my post to apply to your code and you just posted that :P damm u
[Image: dt2.0v2.png]      Happy Birthday, WDZ
01-22-2005 10:33 AM
Profile PM Web Find Quote Report
Stigmata
Veteran Member
*****



Posts: 3520
Reputation: 45
20 / Other / Flag
Joined: Jul 2003
O.P. RE: Php Help
blah, i dont want it to die, because it wont load the rest of my page :)

this is what i did
code:
<?php
$page = htmlentities($_GET['page']) ;
$language = htmlentities($_GET['lan']) ;
if (!isset($_GET['page'])) {
if(!isset($_GET['lan'])) {
include ("pages/code/home.txt");
}
else {
$filename2 = '/pages/code/$language.txt';
if (file_exists($filename2)) {
include("/pages/code/$language.txt");
} else {
   echo "Sorry, The Page Cannot Be Found";
}
}
}
else {
$filename = "pages/code/$language/$page.txt";
if (file_exists($filename)) {
   include("pages/code/$language/$page.txt");
} else {
   echo "Sorry, The Page Cannot Be Found";
}
}
?>


This post was edited on 01-22-2005 at 10:50 AM by Stigmata.
01-22-2005 10:37 AM
Profile PM Web Find Quote Report
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On