943,917 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Marked Solved
  • Views: 779
  • PHP RSS
Sep 16th, 2009
0

Freak include issue!

Expand Post »
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
php Syntax (Toggle Plain Text)
  1. <?php
  2.  
  3. @include($_SERVER['DOCUMENT_ROOT']."/internal/config/global.php");
  4.  
  5. ?>
  6. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  7. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  8. <head>
  9. <title>EZee Web Solutions</title>
  10. <link rel="stylesheet" type="text/css" href="images/style.css" />
  11. </head>
  12. <body>
  13.  
  14. <div id="main_wrapper">
  15.  
  16. <div id="banner">
  17.  
  18. <h1 class="title">Wolfet Tools</h1>
  19.  
  20. <a style="border: none;" href="#"><img src="images/right.png" style="border: none; float: right;" alt="EZee Web Solutions" /></a>
  21.  
  22. </div>
  23.  
  24. <div id="sidebar">
  25.  
  26. <?php
  27.  
  28. get_module( "Members Panel" );
  29.  
  30. ?>
  31.  
  32. <h3>Menu</h3>
  33.  
  34. <ul>
  35.  
  36. <li><a href="?">Home</a></li>
  37. <li><a href="#">Design</a></li>
  38. <li><a href="#">Programming</a></li>
  39. <li><a href="#">Portfolio</a></li>
  40. <li class="end"><a href="#">Contact</a></li>
  41.  
  42. </ul>
  43.  
  44. </div>
  45.  
  46. <div id="banner_extension">
  47.  
  48.  
  49.  
  50. </div>
  51.  
  52.  
  53.  
  54. <div id="content">
  55.  
  56. <?php
  57.  
  58. if( !isset( $_GET['base'] ) ) {
  59. get_page("Home");
  60. }
  61.  
  62. if( $_GET['base'] == "register" ) {
  63. get_page("Register");
  64. }
  65.  
  66. ?>
  67.  
  68. </div>
  69.  
  70. <div id="footer">
  71.  
  72.  
  73.  
  74. </div>
  75.  
  76. </div>
  77.  
  78. </body>
  79. </html>


global.php
php Syntax (Toggle Plain Text)
  1. <?php
  2.  
  3. function get_module( $module_name ) {
  4. $path = $_SERVER['DOCUMENT_ROOT'] . "/internal/modules/" . $module_name . "/config.php";
  5. if( !@include( $path ) ) {
  6. 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 />";
  7. }
  8. }
  9.  
  10. function get_page( $page_name ) {
  11. $path = $_SERVER['DOCUMENT_ROOT'] . "/internal/pages/" . $page_name . "/config.php";
  12. if( !@include( $path ) ) {
  13. 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 />";
  14. }
  15. }
  16.  
  17. ?>

config.php
php Syntax (Toggle Plain Text)
  1. <?php
  2.  
  3. if( !isset( $_GET['page'] ) {
  4. include("form.php");
  5. }
  6.  
  7. if( $_GET['page'] == "checkform" ) {
  8. include("validate.php");
  9. }
  10.  
  11. ?>
  12.  
  13. <h1>Register</h1>
  14. <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>
  15.  
  16. <h3>Take your time</h3>
  17. <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)
  1. <h1>Register</h1>
  2. <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>
  3.  
  4. <h3>Take your time</h3>
  5. <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.
Similar Threads
Reputation Points: 11
Solved Threads: 6
Junior Poster in Training
Froger93 is offline Offline
74 posts
since Sep 2009
Sep 16th, 2009
0

Re: Freak include issue!

Quote ...
if( !@include( $path ) ) {
That part of the syntax is totally wrong. I don't think that an include is not meant to be in an if statement. Also replace the include with the require function which does the same thing but with error reporting. Also I would advice removing those @ symbols. So the above quote should be the following:
php Syntax (Toggle Plain Text)
  1. if(file_exists($path)) {
  2. require( $path );
  3. } else {
Sponsor
Featured Poster
Reputation Points: 410
Solved Threads: 258
Occupation: Genius
cwarn23 is offline Offline
3,004 posts
since Sep 2007
Sep 16th, 2009
0

Re: Freak include issue!

Thanks buddy thats fixed it
Reputation Points: 11
Solved Threads: 6
Junior Poster in Training
Froger93 is offline Offline
74 posts
since Sep 2009
Sep 16th, 2009
0

Re: Freak include issue!

I think is better write in config.php so:
PHP Syntax (Toggle Plain Text)
  1. switch ($_GET['page']) {
  2. case 'checkform':
  3. include("validate.php");
  4. break;
  5. }
Reputation Points: 10
Solved Threads: 3
Newbie Poster
SAMAEL is offline Offline
20 posts
since Sep 2009

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: Itterating - "a" through "zzzz"
Next Thread in PHP Forum Timeline: UML Check





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC