How do I put in a PHP include file on my web page?
I need to put a PHP include file on my webpager but when I run it I get an error message.
This is what I have up now;
<?php include("includes/menu.htm"); ?>
and all I get is this error message. What am I doing wrong?
:: Code ::
Warning: main(menu.htm): failed to open stream: No such file or directory in C:\webstuff\index.htm on line 37
Warning: main(): Failed opening 'menu.htm' for inclusion in C:\webstuff\index.htm on line 37
Back to top
Posted: Feb 28, 04, 13:24 techAdmin
Status: Site Admin
Joined: 26 Sep 2003
Location: East Coast, West Coast? I know it's one of them.
You may not have set your include path in your .htaccess file, to do that, download your .htaccess file in your ftp program, it's a normal text file, open it in your text editor, editplus or whatever you use, add this line:
php_value include_path ".:/usr/www/your_user_folder/your_website_folder/includes"
Please note this is just an example, you will have to get the actual path from your webhoster, or you can get it by using this line of php code in any webpage:
<?php echo $_SERVER['DOCUMENT_ROOT'] ?>
This will print out the actual path to your site folder, then just add the path from the root directory to your includes directory. Remember, it's a very good idea to not have your include directory in your root directory, but somewhere else, since that way noone else can access it from outside the web.
For example, say if your site's absolute path is:
You can simply create a new folder here:
and then set the include path for that, your includes are not accessible to anyone on the web at that point, unless they hack into your server.
Back to top
All times are GMT - 8 Hours