Freak include issue!

Thread Solved

Join Date: Sep 2009
Posts: 36
Reputation: Froger93 is an unknown quantity at this point 
Solved Threads: 4
Froger93 Froger93 is offline Offline
Light Poster

Freak include issue!

 
0
  #1
Sep 16th, 2009
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
  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
  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
  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
  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.
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 1,473
Reputation: cwarn23 has a spectacular aura about cwarn23 has a spectacular aura about cwarn23 has a spectacular aura about 
Solved Threads: 136
cwarn23's Avatar
cwarn23 cwarn23 is offline Offline
Nearly a Posting Virtuoso

Re: Freak include issue!

 
0
  #2
Sep 16th, 2009
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:
  1. if(file_exists($path)) {
  2. require( $path );
  3. } 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
Reply With Quote Quick reply to this message  
Join Date: Sep 2009
Posts: 36
Reputation: Froger93 is an unknown quantity at this point 
Solved Threads: 4
Froger93 Froger93 is offline Offline
Light Poster

Re: Freak include issue!

 
0
  #3
Sep 16th, 2009
Thanks buddy thats fixed it
Reply With Quote Quick reply to this message  
Join Date: Sep 2009
Posts: 20
Reputation: SAMAEL is an unknown quantity at this point 
Solved Threads: 3
SAMAEL's Avatar
SAMAEL SAMAEL is offline Offline
Newbie Poster

Re: Freak include issue!

 
0
  #4
Sep 16th, 2009
I think is better write in config.php so:
  1. switch ($_GET['page']) {
  2. case 'checkform':
  3. include("validate.php");
  4. break;
  5. }
Reply With Quote Quick reply to this message  
Reply


This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC