News:

The "Support Requests" forum is now viewable by guests.

Main Menu

PHP include not working?

Started by hotbox, February 12, 2006, 11:01:10 PM

Previous topic - Next topic

hotbox

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.

dest

try removing all those extra spaces, especially between the < and the ?

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

sixthcrusifix

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.
Visite me website at http://www.sixthcrusifix.com

hotbox

#3
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 )

dest

try just <?php include("sidebar.php"); ?>
meh :P

hotbox

thanks ... I thought that not including the full path slowed down the server.  Thanks again.

sixthcrusifix

#6
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
Visite me website at http://www.sixthcrusifix.com

x

the reason it would have been showing the code is because it must be called from a .php page and not a .html page

dest

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)
meh :P