Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I want to be able to have php scripts in my webpages, but i cant get things working...
e.g. (saved as test.htm):<html>
<head>
<title>monkey</title>
</head>
<body>
<?php
echo "Hello World";
?>
</body>
</html>I can only see a blank page when this loads. I have installed php as well as Apache and IIS, and things seemed to be set up right. Frontpage doesn't seem to recognise the php code. Do I need to edit the PATH variable? Whats going on??? Help!

First, you'll have to save the file as .php, not .htm. The server will only parse the PHP if the file extension is associated with the PHP engine (in the web server, not windows).
If it still doesn't work, you may not have apache or iis set up correctly (use one or the other, not both. Apache is probably the way to go since you're using PHP)
There's no shortage of web tutorials on how to get PHP working with apache...Check out PHP.net.
Luck,
-SN

thanks, that seems to have got things working alot better.
only thing now is that to view my page, the file has to be in "C:\Program Files\Apache Group\Apache2\htdocs" and I only seem to be able to access it via http://localhost/test.php
Is there anyway that I can save the php file where I like, and then just open it as it is, rather than the whole localhost thing?
thanks

You can change apache's default directory to something else, but for the server to parse a file, you need to access it via http, which just loading it into the browser like a local html file doesn't do.
So the short answer to your question is No. However, I mostly use IIS so somebody else here who knows more about apache might have a trick I don't know about.
Good Luck,
-SN

I found a program called DzSoft PHP Editor, which seems to do what I need. You can preview what you're developing as you're doing it, rather than going through the hassle of working from a certain directory and then having to access it via localhost. So, I think I've now got things sorted.
Thanks for all the help.

![]() |
Win98 for Server?
|
browser cant display .tk ...
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |