php question

For everything that's not in any way related to PureBasic. General chat etc...
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

traumatic wrote:
srod wrote:

Code: Select all

System  Windows NT IIS6110 5.2 build 3790  
Sincere condolences! ;)
:)
I may look like a mule, but I'm not a complete ass.
Mistrel
Addict
Addict
Posts: 3415
Joined: Sat Jun 30, 2007 8:04 pm

Post by Mistrel »

I think you misunderstand the purpose of the <?php... ?> tag.

This tag is meant to be used in a .php or other file type that's recognized by the web server. A .php file is no different from a .html file other than the fact that it passes through the php parser. The parser knows what to act upon by what is encased in php tags.

To use the php tags in a .html file is backwards thinking. Just name your files .php.

A good book on PHP is Sam's Teach Yourself PHP in 24 Hours.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

The <?php ?> tags can be embedded in ANY file which is passed to the php engine; anything not enclosed within such tags is ignored by the engine. My problem is getting my remote server to pass html files to the php engine; with Apache - no problem. With IIS...

There are good reasons for wishing to embed php code within a html file; as explained in Sam's Teach Yourself PHP, MySQL and Apache!
:wink:

Now, I need a php script to run immediately before my main page loads in a user's browser. The options, in the absence of the desired solution of having html pages sent to the php engine, therefore, are either to rename my main page www.MyWebsite/index.php which is pretty horrendous for a user having to type that in, or use redirection - which is what I've done. The redirection works very well.

Course, if the user has disabled scripting...
I may look like a mule, but I'm not a complete ass.
Mistrel
Addict
Addict
Posts: 3415
Joined: Sat Jun 30, 2007 8:04 pm

Post by Mistrel »

The php parser can read tags from any file type passed to it, yes, but for what reason do you need it to read .html?
The options, in the absence of the desired solution of having html pages sent to the php engine, therefore, are either to rename my main page www.MyWebsite/index.php which is pretty horrendous for a user having to type that in, or use redirection ..
You shouldn't have to. I can't speak for IIS but Apache will automatically recognize your index.php page by typing just www.MyWebsite.com, unless you have a conflicting index.

Apache will load an index page by order of importance .html/.php/.htm, in that order.

I'm going to guess that you can't get your index page redirected to simply by typing your website name? If you already have an index.html file in your website's root directory your php page won't load first.
The redirection works very well.
Only for those users who have Javascript enabled.

Maybe I'm not understanding the question. Why is it imperative that your web pages have the .html extension?
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

You shouldn't have to. I can't speak for IIS but Apache will automatically recognize your index.php page by typing just www.MyWebsite.com, unless you have a conflicting index.
Well bugger me, I didn't know that -and yes, that works fine! Very nice. :)

Now why the hell didn't I think of even trying that?

That's what it means to be new to all of this Apache and php stuff! :wink: Still, it's good fun learning.

Thanks Mistrel.
I may look like a mule, but I'm not a complete ass.
LuCiFeR[SD]
666
666
Posts: 1033
Joined: Mon Sep 01, 2003 2:33 pm

Post by LuCiFeR[SD] »

you know, thats what I was trying to tell you last night, but I'd had a skinfull lol :P
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Sorry Lucifer, I think you were indeed saying that I should simply use index.php instead of index.html, but I didn't realise even then that the php file would be loaded automatically if the html file was absent!

And I have no excuse because I hadn't touched a drop! :)
I may look like a mule, but I'm not a complete ass.
PurePWNRER
User
User
Posts: 45
Joined: Mon Mar 27, 2006 5:44 am

Post by PurePWNRER »

traumatic wrote:I'm not sure if I fully got this right, but if it's a windows server chances are
high that it's not even running apache but IIS instead.
If so, there's no .htaccess available.

If the server is running apache, your provider should really allow you to
access the .htaccess. I've never come across any provider that forbids
that. I mean, how do you setup error-documents for example?
And you came from the past?, IIS supports .htaccess, mate.
:/ My kingdom for a snippet!
I might bash, But I provide.
traumatic
PureBasic Expert
PureBasic Expert
Posts: 1661
Joined: Sun Apr 27, 2003 4:41 pm
Location: Germany
Contact:

Post by traumatic »

PurePWNRER wrote:And you came from the past?, IIS supports .htaccess, mate.
Does it, mate? Since which version, mate? Do you have any link for me to read, mate?
Good programmers don't comment their code. It was hard to write, should be hard to read.
Dare
Addict
Addict
Posts: 1965
Joined: Mon May 29, 2006 1:01 am
Location: Outback

Post by Dare »

traumatic wrote:
PurePWNRER wrote:And you came from the past?, IIS supports .htaccess, mate.
Does it, mate? Since which version, mate? Do you have any link for me to read, mate?
Well, PurePWNRER has been back and pooped on a few more doorsteps. Wonder why he hasn't responded here. :D


Maybe he is hunting down that link for us. We wait in anxious anticipation!




BTW, wouldn't it be great if IIS supported something like that? Save on all that manual or scripting pooting around. But then perhaps it would all be too easy.
Dare2 cut down to size
traumatic
PureBasic Expert
PureBasic Expert
Posts: 1661
Joined: Sun Apr 27, 2003 4:41 pm
Location: Germany
Contact:

Post by traumatic »

Maybe we're not worth it or something...
Good programmers don't comment their code. It was hard to write, should be hard to read.
mrjiles
Enthusiast
Enthusiast
Posts: 238
Joined: Fri Aug 18, 2006 7:21 pm
Location: IL

Post by mrjiles »

I'm pretty sure IIS doesn't use a .htaccess file ... first off, have you ever tried to name a file in Windows that begins with a period (.)? I think everything is stored in a database.

IIS should have a spot to set the default page(s) though (website properties maybe?)
Post Reply