FreePgs.com Forum

FreePgs Related => Support Requests => Topic started by: hotbox on February 12, 2006, 11:01:10 PM

Title: PHP include not working?
Post by: hotbox on February 12, 2006, 11:01:10 PM
I added the code "

< ?php include ("/fpgs/fpghttpd/hotbox/sidebar.php"); ? >

"
to my index.html file in order to have a menu that can be reused across several pages. For some reason it's not including the menu but actually placing that code ON the page.
is there something I'm missing?

A line I need to add to .htaccess... I have no idea. If there is an easier way to include a common menu across all pages let me know :)

thanks for any replies.
Title: Re: PHP include not working?
Post by: dest on February 13, 2006, 02:39:54 AM
try removing all those extra spaces, especially between the < and the ?

try <?php include("/fpgs/fpghttpd/hotbox/sidebar.php"); ?>
Title: Re: PHP include not working?
Post by: sixthcrusifix on February 13, 2006, 09:31:56 AM
yeah spaced in between <? and ?> are bad, it only registers as php if you use the explicit "<?" and "?>" tags. It's not something you can just space. If that doesn't solve teh problem contact teh admin, the rest of your code is perfect.
Title: Re: PHP include not working?
Post by: hotbox on February 13, 2006, 03:27:16 PM
oh I copied that code from an online tutorial, I guess if they hadn't put the code like that it would have been seen as PHP code... I feel pretty dumb... Trying it without spaces.

Now I get a big fat error message embedded on the web page. ( http://www.freepgs.com/hotbox )
Title: Re: PHP include not working?
Post by: dest on February 13, 2006, 05:34:08 PM
try just <?php include("sidebar.php"); ?>
Title: Re: PHP include not working?
Post by: hotbox on February 13, 2006, 06:38:33 PM
thanks ... I thought that not including the full path slowed down the server.  Thanks again.
Title: Re: PHP include not working?
Post by: sixthcrusifix on February 13, 2006, 09:42:02 PM
Quote from: hotbox on February 13, 2006, 06:38:33 PM
thanks ... I thought that not including the full path slowed down the server.  Thanks again.

That's only if it's not in the directory you're in. If you're including a file that's IN that directory it's fine but if you're grabbing from somewhere else use the full path.

May I make a suggestion? Include the full path anyway but as a Variable.
<?php
$path 
"/fpgs/fpgshttpd/hotbox";

include(
"$path/sidebar.php");
?>


That way if you move to a different server you can just go through and change that variable once instead of finding every "include" And changing the whole path.



As to your error message:

Quote from: dest on February 13, 2006, 02:39:54 AM
try removing all those extra spaces, especially between the < and the ?

try <?php include("/fpgs/fpghttpd/hotbox/sidebar.php"); ?>


OH That's your problem, you have teh path wrong dude, it's fpgshttpd.

It's <?php include("/fpgs/fpgshttpd/hotbox/sidebar.php"); ?>

:D
Title: Re: PHP include not working?
Post by: x on February 13, 2006, 10:32:51 PM
the reason it would have been showing the code is because it must be called from a .php page and not a .html page
Title: Re: PHP include not working?
Post by: dest on February 14, 2006, 02:08:50 AM
With .htaccess, you can set up any file type to accept php.  Quite useful for dynamic images when forums only accept certain extensions.  (Of course, the other way around that is to make a directory look like a file, like naming a folder blah.png)