This Message Forum is no longer in use

Please use the new Bravenet Help Forums FOUND HERE

General Forum
This Forum is Locked
Author
Comment
Includes pages 'how-to' help

There used to be an article on Bravenet that dealt with this, but the tips library seems rather devoid of tips since Bravenet redesigned the site and swithced to php.
Can someone help me with this...I know its really simple, but I forget how to do it.
I have been using php of late (a couple of prepackaged scripts) but find these packages to be limiting or difficult to edit to obtain your own unique layout.
Therefore I am resorting to html for the site design and just using php for the 'dynamicness'.
I have 2 questions you could maybe help me with.
1. I am using FrontPage for the html. When I include another page within a page, the inserted code those **** web-bot bits. I do NOT want to mess with installing FrontPage extensions and all that. How do I, simply, code for an include page? I believe I also need, then, to save the page with an .shtml extension?
and
2. If the included page is a php page, can I still save the html page as an .shtml, or does it have to be saved as a .php page in order for the browser to read/execute the php?

Thanks for any help you can give.

Re: Includes pages 'how-to' help


I don't have the answer, but I know a place where I'm sure they do: right here.

Jim

Re: Re: Includes pages 'how-to' help

Thanks for the quick reply Jim, but that wasn't what I was after.
The page you directed me to is for php includes, which I know how to do.
I wanted info on how to do html includes and whether I have to save the page as a .php if that included page is a php page.
The reason I don't want to have to save the html page as a .php page is because I cannot view php locally (a stupid XPHome Ed shortcoming). In order to view any php in a browser, I have to upload every little change in order to see if it works. Its a lot quicker if I can view it locally.

Re: Re: Re: Includes pages 'how-to' help


Can't you run a PHP engine like PHPDEV? Runs on XP, not sure about the home edition though.
Oh, and I'm sure the gurus on that site can answer your PHP/SHTML/DHTML questions. One of the things I learned there is that you do not need to name your PHP pages something.php. And include page could (for your convenience) for example be header.inc, just make sure you refer to the proper page.

Having said that, some servers may only "run" .php pages, and "send" the others as HTML - but that has to do with the server set-up, not with PHP. See this discussion for example.

Jim

Re: Re: Re: Re: Includes pages 'how-to' help

"Can't you run a PHP engine like PHPDEV? Runs on XP, not sure about the home edition though. "

Hahaha ...you give me WAY too much credit! LOL
I have the source code for Apache, MySQl and PHP. Even tried installing it once...b******d if I could ever get it to work tho.

"One of the things I learned there is that you do not need to name your PHP pages something.php"

And I guess that pretty much answers my questions.
But to clarify (just to make sure I am understanding you), you are saying I can include (any) page in an html page using a (properly formatted/flagged/tagged) php "include" statement, and still save it as an html page and the php will execute properly?

Re: Re: Re: Re: Re: Includes pages 'how-to' help


PHPDEV is a self-installer, it includes Apache, PHP and MySQL - not the very latest versions though. I know as good as zip about the three products, but I managed to get them up and running every time. It even runs on W95! Try it: it won't install anything in Windows or WindowsSystem or so.

About your second question: wait and see in a couple of hours.

Jim

Re: Re: Re: Re: Re: Re: Includes pages 'how-to' help



is the html server side include code that will include the code from myfile.inc at the point specified. It requires SSI to be installed and enabled on the server and a file suffix of .shtml (unless you add AddHandler server-parsed .htm .html to the .htaccess file in which case you can use .htm and/or .html suffixes instead.

Note that this still requires a web server that has server side include support or the code will not be included.

regards,
Stephen Chapman


Ask Felgall for Computer Help

Re: Re: Re: Re: Re: Re: Re: Includes pages 'how-to' help

When I first acquired my hosting, my host provider has avaialble a little handy-dandy "Under construction" countdown timer that you can use.
The instructions say to (after editing it to your requirements) save it as an shtml file.
I would assume therefore that this means server side includes are installed with my host?
Or should I never assume anything?

Re: Re: Re: Re: Re: Re: Re: Re: Includes pages 'how-to' help

Never assume anything

Unless as previously mentioned you have diddled around with file types, your server will ONLY include other files if your server recognizes the file extension of the main file as being one that has to be created on the server before being sent to the visitor's computer.

If you use html includes (often called SSI), then your file name needs to end with .shtml so that your server knows it has to execute something other than just sending the file.

If you want scripted server side includes such as those that php uses, then you need to have php installed on your server, and you need to name you files with the .php file extension - again, so your server knows it has to do "something" with the file before sending it on its way.

If your host suggests a .shtml file then html includes are enabled for you. If you have the php package on your server - ask your host - then any .php can include anything. Typical syntax would be:

include("something.php");
... more code
... more code
include("something_else.php");
... more code
?>

Re: Re: Re: Re: Re: Re: Re: Re: Re: Includes pages 'how-to' help

I know a .php file can include anything...but I was having the problem that I was unable to view php locally. Hence my original question about whether I could save a file that included php wuth an extension OTHER than .php.

It is moot now anyway.
The PHPDev package Jim suggested is just what I needed.
Although I do have another question for Jim (as he has said that he has had success using PHPDev.
When creating php files, in order to view them locally (i.e. access them from "localhost"), then where should I save those files to?
Other php files I have on my system still open in my default php editor, and not the web browser.
I'm guessing (as opposed to "assuming" :-P )that I need to create my own testing folder within the www folder inside c:/PHPDev in order to access them through localhost??

Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Includes pages 'how-to' help

I'm assuming you got phpdev via FirePages site in Australia (which is where Jim got his). I have mine set up simply with a subfolder named www in the phpdev folder; then www is divided into differently named folders for the sites I'm working on.

To view anything locally 'live' (with Apache running), I navigate to http://localhost/phpdev/www/somesite/index.php or similar.

Once testing is finished, upload to appropriate web server (I always use relative addressing), change any MySQL connection data to suit the remote web server and I'm done.

I don't know your php expertise level, but one of the places where Jim learned is the Llamasery.com tutorials mirrored at the site listed above.

hth

Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Includes pages 'how-to' help

My "expertise level" could be described thus:
I have script A...script B looks like it has some useful functions. If I think can figure out how to merge script A with script B, then I will try to do so. Generally, after 4 or 5 tries I have one of 2 possible results: it worked, or it failed miserably, emphasis on the miserably.
Ask me to create a script from scratch, and I would probably recommend a good psychiatrist for you.
Although, in my defense, I AM learning, and make less mistakes than I did 6 months ago...of course I have learned from past errors and don't attempt so much script merging now-a-days...hehe
Just as an example of how bad I am...using a SAMS Teach Yourself book on php (which I think is based on PHP2) there is a simple 65 line script for creating your own shopping cart (BASIC!).
I screwed that up.
Parse error line 13, unexpected "."
Fixed that.
Parse error line 17, unexpected T VARIABLE.
Now...I have NO CLUE what a T VARIABLE is.

You getting the picture?


I think this thread has about reached its "Use-By" date, and yes, y'all have answered my questions...not only with helpful answer, but timely ones too!!
And I thank you for that.

Given my lack-luster php skills...I will probably see y'all again.

in conclusion

Been there, done that, got the t-shirt, etc.

php help is going to be pretty sparse in the Bravenet forums since BN hosting doesn't support it (yet). If the 'help' site I cited earlier isn't doing it for you, hop on over to http://forums.llamasery.com and look for Jim or me there - and you can find some sympathetic php wizards who can really help.