LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 06-24-2004, 02:43 PM   #1
msound
Member
 
Registered: Jun 2003
Location: SoCal
Distribution: CentOS
Posts: 465

Rep: Reputation: 30
php include


alrighty let me explain what I'm trying to do. I made an online form where a user can choose a month and a week then hit submit. The php page it POST's to turns the to variables into a string

$mon = $_POST[month];
$week = $_POST[week];

$getfile = $mon$week.php;

include ($getfile);

Pretty darn easy right? Well the problem is I don't know how to write a check function that makes sure the file exists before php tries to include it. Basically when the user enters a month and week that I don't have a file for I get a long php error message. I'd like to set it up so it just displays a message "Sorry we do not have a file for that month and week". Any help would be greatly appreciated.
 
Old 06-24-2004, 03:15 PM   #2
logicdisaster
Member
 
Registered: Jun 2004
Posts: 41

Rep: Reputation: 15
use file_exists($getfile);
so
$mon = $_POST[month];
$week = $_POST[week];

$getfile = $mon$week.php;
if(file_exists($getfile)){
include ($getfile);
} else {
echo "Error Message";
}
 
Old 06-24-2004, 04:21 PM   #3
msound
Member
 
Registered: Jun 2003
Location: SoCal
Distribution: CentOS
Posts: 465

Original Poster
Rep: Reputation: 30
awesome, thanks for the reply I'll try it first thing tomorrow morning!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP include it-s Programming 3 10-05-2005 11:07 PM
PHP include() not working kodon Slackware 13 08-10-2004 06:05 AM
php include files abrb220 Programming 2 10-27-2003 07:54 AM
PHP Path include ..:eMa:.. Programming 4 09-25-2003 01:59 AM
php - include, require and arrays gui10 Programming 1 02-05-2002 08:54 AM


All times are GMT -5. The time now is 09:33 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration