hosted by liquidweb


Go Back   Web Hosting Talk : Web Hosting Main Forums : Programming Discussion : Make a php script show on a .html page?
Reply

Programming Discussion Discussions related to web programming languages and other related issues. Topics may include configuration, optimization, practical usage and database connectivity.
Forum Jump

Make a php script show on a .html page?

Reply Post New Thread In Programming Discussion Subscription
 
Send news tip View All Posts Thread Tools Search this Thread Display Modes
  #1  
Old 05-08-2004, 04:44 PM
1jetsam 1jetsam is offline
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!

__________________
Quate.net

Reply With Quote


Sponsored Links
  #2  
Old 05-08-2004, 06:36 PM
t c t c is offline
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"-->

Reply With Quote
  #3  
Old 05-08-2004, 06:49 PM
1jetsam 1jetsam is offline
WHT Addict
 
Join Date: Feb 2004
Posts: 134
For example, maybe?:
Code:
<!--#include virtual="myfile.php"-->
Would that work?

__________________
Quate.net

Reply With Quote
Sponsored Links
  #4  
Old 05-08-2004, 06:56 PM
t c t c is offline
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.

Reply With Quote
  #5  
Old 05-08-2004, 07:32 PM
1jetsam 1jetsam is offline
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.

__________________
Quate.net

Reply With Quote
  #6  
Old 05-08-2004, 07:47 PM
1jetsam 1jetsam is offline
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);
?>

__________________
Quate.net

Reply With Quote
  #7  
Old 05-08-2004, 09:27 PM
t c t c is offline
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.

Reply With Quote
  #8  
Old 05-08-2004, 09:37 PM
Barti1987 Barti1987 is offline
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??

Reply With Quote
  #9  
Old 05-08-2004, 09:38 PM
Barti1987 Barti1987 is offline
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

Reply With Quote
  #10  
Old 05-08-2004, 09:48 PM
t c t c is offline
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.

Reply With Quote
  #11  
Old 05-08-2004, 09:54 PM
Barti1987 Barti1987 is offline
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" --> ?

Reply With Quote
  #12  
Old 05-08-2004, 10:00 PM
mr_wuss mr_wuss is offline
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

Reply With Quote
  #13  
Old 05-08-2004, 10:06 PM
Barti1987 Barti1987 is offline
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?!

Reply With Quote
  #14  
Old 05-08-2004, 10:18 PM
digitok digitok is offline
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

Reply With Quote
  #15  
Old 05-08-2004, 10:19 PM
Barti1987 Barti1987 is offline
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!!

Reply With Quote
Reply

Related posts from TheWhir.com
Title Type Date Posted
Pingdom Talks Top Web Hosting Cities and Countries Web Hosting News 2013-03-27 18:49:54
Whistleblower Site Cryptome Hacked, Infects PCs with Drive-By Exploits Web Hosting News 2012-02-14 14:48:24
Control Panel cPanel Launches New Apache Configuration Script Web Hosting News 2011-12-28 19:41:39
Blogging Site LiveJournal Hit by Ongoing DDoS Attack Web Hosting News 2011-12-08 16:35:38
Software Developer Softaculous Launches Softaculous Auto Installer Version 3.8 Web Hosting News 2011-11-25 15:34:49


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump
Login:
Log in with your username and password
Username:
Password:



Forgot Password?
Advertisement:
Web Hosting News:



 

X

Welcome to WebHostingTalk.com

Create your username to jump into the discussion!

WebHostingTalk.com is the largest, most influentual web hosting community on the Internet. Join us by filling in the form below.


(4 digit year)

Already a member?