
05-08-2004, 04:44 PM
|
|
WHT Addict
|
|
Join Date: Feb 2004
Posts: 134
|
|
Make a php script show on a .html page?
I know one way, which does not seem to work for me which is a java include, but I know other people have done this with php and java so..
I was wondering how to make it work, so that someone without php support can still use a php script from another site (an include?).
Thanks for the help!
|

05-08-2004, 06:36 PM
|
|
Web Hosting Master
|
|
Join Date: Mar 2003
Location: VA
Posts: 640
|
|
I think what you are looking for is SSI (Serverside Includes).
The proper way to do this is supplying the path and not absolute url. However, you could probably get away with supplying the absolute url.
Code:
Correct:
<!--#include virtual="/path/to/file.ext"-->
Incorrect (might work still though):
<!--#include virtual="http://www.domain.com/path/file.ext"-->
|

05-08-2004, 06:49 PM
|
|
WHT Addict
|
|
Join Date: Feb 2004
Posts: 134
|
|
For example, maybe?:
Code:
<!--#include virtual="myfile.php"-->
Would that work?
|

05-08-2004, 06:56 PM
|
|
Web Hosting Master
|
|
Join Date: Mar 2003
Location: VA
Posts: 640
|
|
Yes it would but, if your host doesn't support php then it will not display the php output and will display source only.
|

05-08-2004, 07:32 PM
|
|
WHT Addict
|
|
Join Date: Feb 2004
Posts: 134
|
|
Ok, thats why it doesn't work on my computer, because I don't have php installed (it doesn't want to, it has feelings.)
Nope, didn't work. I have a php server, but it isn't working... let me try on another server.
|

05-08-2004, 07:47 PM
|
|
WHT Addict
|
|
Join Date: Feb 2004
Posts: 134
|
|
...and it doesn't work on the second server.
The php script itself is working, just not the .html page with the php results. it shows nothing on that page.
Here: http://www.cyberosis.com/forum/counter.html (and /count.php)
http://www.hostultra.com/~1jetsam/counter.html (and /count.php)
source:
counter.html
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Counter</title>
</head>
<body>
<!--#include virtual="count.txt"-->
</body>
</html>
count.php
Code:
<?php
$fp = fopen("counterlog.txt", "r");
$count = fread($fp, 1024);
fclose($fp);
$count = $count + 1;
echo "Site Views: " . $count . "";
$fp = fopen("counterlog.txt", "w");
fwrite($fp, $count);
fclose($fp);
?>
|

05-08-2004, 09:27 PM
|
|
Web Hosting Master
|
|
Join Date: Mar 2003
Location: VA
Posts: 640
|
|
The reason why it's not working is because you cannot run php period and only way to display counter results via a php script is if you have php on there.
On your 'counter.html' you have count.txt and you should have 'count.php'. Of course it's not going to work though.
|

05-08-2004, 09:37 PM
|
|
Web Hosting Master
|
|
Join Date: Mar 2004
Location: USA
Posts: 4,342
|
|
hay tc..
i tried a very easy script..
conter.php
PHP Code:
<?
echo 'aziz';
?>
and the htm file was:
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<!--#include virtual="counter.php" -->
</body>
</html>
it didnt work??
are you sure of it..
i never knew u can include php in html??
|

05-08-2004, 09:38 PM
|
|
Web Hosting Master
|
|
Join Date: Mar 2004
Location: USA
Posts: 4,342
|
|
i tried it with html, htm
i also trued the include as file(instead of virtual), didnt work
|

05-08-2004, 09:48 PM
|
|
Web Hosting Master
|
|
Join Date: Mar 2003
Location: VA
Posts: 640
|
|
Perhaps you may want to try changing 'virtual to 'file'
Code:
<!--#include file="counter.php" -->
Also this is not using php in html. This is using server-side includes in html.
Oh yeah and I forgot to mention, you need to make sure the file that will have the include function on it needs to be an either '.shtm' or '.shtml' extension.
|

05-08-2004, 09:54 PM
|
|
Web Hosting Master
|
|
Join Date: Mar 2004
Location: USA
Posts: 4,342
|
|
I already did try the file part.. it didnt work...
What do u mean by .shtml or .shtm...
so do this
<!--#include file="counter.shtml" --> ?
|

05-08-2004, 10:00 PM
|
|
Junior Guru
|
|
Join Date: Apr 2004
Posts: 191
|
|
it means that apache will not look for includes unless the extension .shtml is there
unless you over ride that with a .htaccess file.
.shtml serverside parse / .html = pure output
|

05-08-2004, 10:06 PM
|
|
Web Hosting Master
|
|
Join Date: Mar 2004
Location: USA
Posts: 4,342
|
|
Quote:
Originally posted by mr_wuss
it means that apache will not look for includes unless the extension .shtml is there
unless you over ride that with a .htaccess file.
.shtml serverside parse / .html = pure output
|
Strange..
I made an .htaccess file with that line... still is not working?!
|

05-08-2004, 10:18 PM
|
|
Web Hosting Master
|
|
Join Date: Jan 2003
Location: Perth, WA, Australia
Posts: 1,276
|
|
You can make Apache parse .html files as PHP if you like.
__________________
nu-metal.org :: coming soon
|

05-08-2004, 10:19 PM
|
|
Web Hosting Master
|
|
Join Date: Mar 2004
Location: USA
Posts: 4,342
|
|
I am running on a windows server. I think that it what is causing the problem..
I will try using the linux serverside.
Nope... getting error 500!!
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
| Postbit Selector |
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|
|
| Login: |
|
|
| Advertisement: |
|
|
| Web Hosting News: |
|
|
|