Forum Moderators: coopster

Message Too Old, No Replies

Need help with PHP script

Include it in htm

         

Fryman

5:39 pm on Jun 12, 2004 (gmt 0)

10+ Year Member



My buddy icon site uses php pages to call a htm page. For example, if I want to go to web2.php, this is what it has:

web2.php:
<?
$BASE_DIR=".";
$BASE_URL=".";
require_once("lib/common.php");
page("web2");
?>

So, a page called web2.htm gets inserted in th middle of my template.

I am having a terrible time. I want to insert a link exchange script. The instructions say that you can put a line of code into any page and it will call the script.
Well, I created a page called web3.htm, and I put the following in it:
<?php
require_once("../partners/include_categories.php");
?>

However, include_categories.php just refuses to load. I have tried anything I can imagine, I have parsed php htm pages, so that shouldn't be a problem. I just can't get my script to show on the page. Can anyone give me an idea of what is wrong? If I go directly to web2.htm, I can see the script, but I just can't find a way to insert it into my website. If you need a URL so you can check out the site, please send me a sticky, this is just so damm frustrating!

Thank you

isitreal

6:10 pm on Jun 12, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Add this line to your htaccess file, or your httpd.conf file if you have access to apache.

php_value include_path ".:/server/path/to/your/includes"

This is assuming the script is running on a *nix machine, if it's running on windows and your stuff is on c: it's this:

php_value include_path ".;c:/server/path/to/your/includes"

.:/ or .;c:/ that is.

includes would be your includes folder, generally it's considered a good idea to not have your includes folder be accessible over the web,

ie: /www/usr/yoursitemainfolder/sitefolder/includes
is not as good as
/www/usr/yoursitemainfolder/includes

then when you include the file on the page, you only have to put the path to the includes from the includes folder, which is now acting like the root directory for your includes, like this:

include("yourfile.php");

this works anywhere on your site.

Fryman

6:29 pm on Jun 12, 2004 (gmt 0)

10+ Year Member



It's UNIX, but I don't see any includes folder on my server.

isitreal

6:51 pm on Jun 12, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



there is no includes folder, that's a folder you make, like any other folder, you could call it 'fred', doesn't make any difference. Generally people call it 'includes' for obvious reasons. The location is what does somewhat matter, it's a good habit to not have it accessible over the web, so you want it above the site root folder if possible.

Oh, I forgot, if you do use .htaccess to do this, make sure you include a linebreak after the last line of code on the .htaccess file, otherwise you may get a 500 server error when you try to access the site.

If you don't know what your .htaccess file is, check your site root folder for that file, download it, in ASCII mode, not Binary, save it as .htaccess, upload it. If you don't have that file, make one in a text editor, save it as .htaccess, then upload it.

Fryman

7:17 pm on Jun 12, 2004 (gmt 0)

10+ Year Member



Sent you a sticky mail... let me know what you think

Thanks

isitreal

7:37 pm on Jun 12, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



If you sent a sticky, I didn't get it, sorry, I'll check back later, try sending it again.

Fryman

7:45 pm on Jun 12, 2004 (gmt 0)

10+ Year Member



Sent again, hope it gets there

isitreal

8:00 pm on Jun 12, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



for others reading: the problem is that the page is not parsing as php with a php extension while a .htm page is parsing correctly as php.

isitreal

12:01 am on Jun 13, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



This crossed my mind, even though I never use this:
RemoveHandler .html .htm
which you have in your .htaccess file, maybe your server requires it, I've never seen that, but maybe it does, have you tried:
RemoveHandler .html .htm .php

, since htm files are getting parsed, and php files aren't?

I would try that, see if it works, then try commenting out the removeHandler line:
#RemoveHandler....
upload it and see if it works.

Then try putting some gibberish in a file, save it as .htaccess in a non root directory, make one called 'test', have that .htaccess file in there, then try accessing a test file in that directory, this is to make sure that your webserver is even using .htaccess files. That's good to determine for sure before going on.

if you make a file /test/test.htm and a file /test/.htaccess

and then put some random characters in the .htaccess file, like
oaww;oteijha;efja;
you should get a 500 server error when you try to access /test/test.htm, if you get no error then your server is not allowing you to run .htaccess files.