Cerb 0 Report post Posted May 2, 2007 (edited) My PHP include scripts were working fine for a long time until one day they simply decided to give me errors that I can't seem to fix.I deleted the original homepage because of this and because it was time for a new layout anyways. I'm still having trouble, however. The site is set up so that the index page is the only page with formatting. This is the page that provides the layout. The content pages of the site are accessible through hyperlinks, which are clicked to include the content on the index page.In the area of index.php where I want to include the content I use this code: <?php include("$page");?> The hyperlinks that tell the index.php to include them on it are coded in this way:<a href="index.php?page=pagename.html">Page Name</a> However, when I visit the index page I get the following error:Warning: include() [function.include]: Failed opening '' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/cerb/public_html/index.php on line 20?> It may help your understanding of my problem if you visit cerb.trap17.comWhat could be the problem? This is particularly confusing since they were perfectly sound at one time, and suddenly no longer worked. Edited May 2, 2007 by Cerb (see edit history) Share this post Link to post Share on other sites
shadowx 0 Report post Posted May 2, 2007 Have you ensured that the $page variable is accessed via the $page = $_GET['page']; code?Otherwise it wont get any value for the variable $page as it doesn't have a value yet.It seems like the $page variable has no value as the include file says that the file it is looking for is '' which is basically NULL so it seems like theres a problem with assigning a value to that variable and it could be to do with what i said above. Share this post Link to post Share on other sites
Cerb 0 Report post Posted May 3, 2007 I've actually got it working now. For some reason, though, that original script that I provided above did, in fact, work for a long while. Strange. Share this post Link to post Share on other sites
salamangkero 0 Report post Posted May 3, 2007 I've also run into a lot of developers who do that. Access get variables directly, I mean.It does seem to me that an older version of PHP once supported that. However, as of PHP5 (I'm not sure about PHP4), POST and GET variables had to be accessed using the appropriate indices in the $_GET and $_POST array. So instead of $page, you'd be accessing $_GET['page']Oh yeah, I know you already got it working, just wanted to point that out Share this post Link to post Share on other sites
shadowx 0 Report post Posted May 3, 2007 As its still relative to the thread, i think that there is a setting in php.ini that allows for a the global variables to be accessed directly, though here at T17 and i think by default, that is disabled for security reasons. That caused me some trouble when i first got hosted here. Good to see you got it sorted though, did you have to do anything or did it just start working again? Share this post Link to post Share on other sites
Cerb 0 Report post Posted May 4, 2007 (edited) I had done what you stated above. I don't know how to code PHP myself (although I've been meaning to learn for a while, now), but I found a site that mentioned that that was the proper way to do it. Edited May 4, 2007 by Cerb (see edit history) Share this post Link to post Share on other sites
dwayne12 0 Report post Posted May 9, 2007 <?php // The get variable value $page = $_GET['page']; switch($page) { case "home": include "http://http://ww38.yoursite.com/home.html&%2334;; break; case "downloads": include "http://http://ww38.yoursite.com/downloads.html&%2334;; break; case "contact": include "http://http://ww38.yoursite.com/contact.html&%2334;; break; // The default included page if no value is supplied to the variable default: include "http://http://ww38.yoursite.com/home.html&%2334;; break; } ?> Theres a quick way to do it. Notice from jlhaslip: Code tags added Share this post Link to post Share on other sites