| | |
Freak include issue!
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
•
•
Join Date: Sep 2009
Posts: 36
Reputation:
Solved Threads: 4
Hey guys,
I have been working on some code and have struck a problem, I tried to make the code as easy as possible to edit at a later date.
The issue comes when I include a config file from a directory for a certain page, this config file decides which document related to the current page to display, the issue is that when I try to include the documents from the config file I just get white space and the script seems to die but with NO errors.
Am I missing something?
index.php
global.php
config.php
form.php
Any help would be great, thanks.
I have been working on some code and have struck a problem, I tried to make the code as easy as possible to edit at a later date.
The issue comes when I include a config file from a directory for a certain page, this config file decides which document related to the current page to display, the issue is that when I try to include the documents from the config file I just get white space and the script seems to die but with NO errors.
Am I missing something?
index.php
php Syntax (Toggle Plain Text)
<?php @include($_SERVER['DOCUMENT_ROOT']."/internal/config/global.php"); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>EZee Web Solutions</title> <link rel="stylesheet" type="text/css" href="images/style.css" /> </head> <body> <div id="main_wrapper"> <div id="banner"> <h1 class="title">Wolfet Tools</h1> <a style="border: none;" href="#"><img src="images/right.png" style="border: none; float: right;" alt="EZee Web Solutions" /></a> </div> <div id="sidebar"> <?php get_module( "Members Panel" ); ?> <h3>Menu</h3> <ul> <li><a href="?">Home</a></li> <li><a href="#">Design</a></li> <li><a href="#">Programming</a></li> <li><a href="#">Portfolio</a></li> <li class="end"><a href="#">Contact</a></li> </ul> </div> <div id="banner_extension"> </div> <div id="content"> <?php if( !isset( $_GET['base'] ) ) { get_page("Home"); } if( $_GET['base'] == "register" ) { get_page("Register"); } ?> </div> <div id="footer"> </div> </div> </body> </html>
global.php
php Syntax (Toggle Plain Text)
<?php function get_module( $module_name ) { $path = $_SERVER['DOCUMENT_ROOT'] . "/internal/modules/" . $module_name . "/config.php"; if( !@include( $path ) ) { echo "<br /><span style=\"font-family: Sans-Serif; color: #ff0000;\"><p><b><u>FATAL ERROR:</u></b> There is an internal issue with the following module: <b>" . $module_name . "</b>.</p><p>Unfortuantely the path doesn't contain the required file: <b>" . $path . "</b>.</p></span><br />"; } } function get_page( $page_name ) { $path = $_SERVER['DOCUMENT_ROOT'] . "/internal/pages/" . $page_name . "/config.php"; if( !@include( $path ) ) { echo "<br /><span style=\"font-family: Sans-Serif; color: #ff0000;\"><p><b><u>FATAL ERROR:</u></b> There is an internal issue with the following page: <b>" . $page_name . "</b>.</p><p>Unfortuantely the path doesn't contain the required file: <b>" . $path . "</b>.</p></span><br />"; } } ?>
config.php
php Syntax (Toggle Plain Text)
<?php if( !isset( $_GET['page'] ) { include("form.php"); } if( $_GET['page'] == "checkform" ) { include("validate.php"); } ?> <h1>Register</h1> <p>Thankyou for signing up to use our tools. Please complete the following form in full. All fields marked with <font style="color: Red;">*</font> are required and <b>must</b> be filled in.</p> <h3>Take your time</h3> <p>Please take your time and know that this form is confidential and we will in no way share your details or use them in an inappropriate way.</p>
form.php
php Syntax (Toggle Plain Text)
<h1>Register</h1> <p>Thankyou for signing up to use our tools. Please complete the following form in full. All fields marked with <font style="color: Red;">*</font> are required and <b>must</b> be filled in.</p> <h3>Take your time</h3> <p>Please take your time and know that this form is confidential and we will in no way share your details or use them in an inappropriate way.</p>
Any help would be great, thanks.
•
•
•
•
if( !@include( $path ) ) {
php Syntax (Toggle Plain Text)
if(file_exists($path)) { require( $path ); } else {
Try not to bump 10 year old threads as it can be really annoying.
Like php then read my website at http://syntax.cwarn23.net/
Star-Trek-Atlantis - now that's what I call a movie ^_^
My favourite PC. - MacGyver Fan
Bad english note: dis-iz-2b4u
Like php then read my website at http://syntax.cwarn23.net/
Star-Trek-Atlantis - now that's what I call a movie ^_^
My favourite PC. - MacGyver Fan
Bad english note: dis-iz-2b4u
I think is better write in config.php so:
PHP Syntax (Toggle Plain Text)
switch ($_GET['page']) { case 'checkform': include("validate.php"); break; }
![]() |
Similar Threads
- In file included from my file .cpp (C++)
- (netbeans) issue about friend function (C++)
- convert lower case letters to uppercase and vice-versa (C++)
- calling function issue (C)
- Comments about browser window spam issues (Viruses, Spyware and other Nasties)
- C++ Programming issue (C++)
- PHP's include function ??? (PHP)
- setting width and fill character...(a compiler issue?) (C++)
- Kernel Version of Mandrake and error message (*nix Software)
Other Threads in the PHP Forum
- Previous Thread: Itterating - "a" through "zzzz"
- Next Thread: UML Check
| Thread Tools | Search this Thread |







