Current location: Hot Scripts Forums » Programming Languages » PHP » php on a html page


php on a html page

Reply
  #1 (permalink)  
Old 01-30-04, 10:59 AM
Bonzo's Avatar
Bonzo Bonzo is offline
Coding Addict
 
Join Date: Jan 2004
Posts: 340
Thanks: 0
Thanked 0 Times in 0 Posts
php on a html page

This is daft question but I dont know why it wont work :

I am doing a bit of a site redesign and am creating a html page using css for the page layout etc.

I want to include a bit of php in one of the divisons but am having a problem as nothing seems to work.

I have tried <?php ?>, <? ?> and <% %>.

Can anyone point me in the right direction please.

Anthony

P.S. Not just this time, it happened before and I just used php for the whole page.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 01-30-04, 11:04 AM
<?Wille?> <?Wille?> is offline
Junior Code Guru
 
Join Date: Jan 2004
Location: Helsinki, Finland
Posts: 666
Thanks: 0
Thanked 0 Times in 0 Posts
I dont know where on the page and how.. but:

you can use atleast <?php ?> and <? ?> .. every page that has the least php in it must be saved with a php extension (.php .php3 etc.).

good luck
Wille
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 01-30-04, 11:20 AM
Bonzo's Avatar
Bonzo Bonzo is offline
Coding Addict
 
Join Date: Jan 2004
Posts: 340
Thanks: 0
Thanked 0 Times in 0 Posts
A bit more detail

Right I have save the file as "main.html" which you are saying is the problem Willie ?

The top of the page withe the php bit below.

Anthony

<html>
<head>
<title>main page</title>
<link rel="stylesheet" href="layout.css">
</head>
<body>

<div id="nav">

<?php
echo "test";
?>

</div>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 01-30-04, 11:27 AM
Bonzo's Avatar
Bonzo Bonzo is offline
Coding Addict
 
Join Date: Jan 2004
Posts: 340
Thanks: 0
Thanked 0 Times in 0 Posts
answer ?

Call the page main.php not main.html and carry on as before ?

Just out of interest how do search engins deal with .php pages instead of .htm or .html ?

Anthony
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #5 (permalink)  
Old 01-30-04, 01:43 PM
NeverMind's Avatar
NeverMind NeverMind is offline
Community VIP
 
Join Date: Aug 2003
Location: K.S.A
Posts: 2,257
Thanks: 0
Thanked 2 Times in 1 Post
Quote:
Just out of interest how do search engins deal with .php pages instead of .htm or .html ?
just like any ASCII file

and yes, you need to rename your files extensions to .php and carry on ..
all you need when you want to use php is to open its tags first ..
__________________
PHPSimplicity
We don't need a reason to help people - Zidane [FF9]
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #6 (permalink)  
Old 01-30-04, 06:21 PM
Bonzo's Avatar
Bonzo Bonzo is offline
Coding Addict
 
Join Date: Jan 2004
Posts: 340
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks

Thnks Wille & NeverMind; I will give that a go.

Anthony
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #7 (permalink)  
Old 01-31-04, 08:45 AM
whl626 whl626 is offline
Newbie Coder
 
Join Date: Jan 2004
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by Bonzo
Thnks Wille & NeverMind; I will give that a go.

Anthony
Someone just taught me a way to save a file as .html with php script in it. Using the .htaccess file and save this line into it.

AddHandler application/x-httpd-php .php .php3 .htm .html .phtml
__________________
Learn English every day
http://englishdaily626.com
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #8 (permalink)  
Old 01-31-04, 08:49 AM
NeverMind's Avatar
NeverMind NeverMind is offline
Community VIP
 
Join Date: Aug 2003
Location: K.S.A
Posts: 2,257
Thanks: 0
Thanked 2 Times in 1 Post
true, but this is an advanced way to do it ..
__________________
PHPSimplicity
We don't need a reason to help people - Zidane [FF9]
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #9 (permalink)  
Old 02-06-04, 08:37 AM
dirtydevil dirtydevil is offline
New Member
 
Join Date: Feb 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Using .htaccess file

Quote:
Someone just taught me a way to save a file as .html with php script in it. Using the .htaccess file and save this line into it.

AddHandler application/x-httpd-php .php .php3 .htm .html .phtml
If you do this it means that all .php .php3 .htm .html .phtml files will be parsed by PHP. This can put extra strain on the web server (Slowing respons times on loaded servers) so it is better to seperate the files into .html and .php
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #10 (permalink)  
Old 02-06-04, 11:40 PM
tltran tltran is offline
Newbie Coder
 
Join Date: Jan 2004
Location: Montreal
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by dirtydevil
If you do this it means that all .php .php3 .htm .html .phtml files will be parsed by PHP. This can put extra strain on the web server (Slowing respons times on loaded servers) so it is better to seperate the files into .html and .php
Actually you can call your file with every extension you want.

and you just have to put your extension into the list that it.


AddHandler application/x-httpd-php .php .php3 .htm .html .phtml .zoro .php500 or whatever you want.
__________________
Thanh Liem Tran
When You have to run, you have to run
http://www.irunsoft.com
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
how do i make php open another web page? wonderland PHP 6 09-23-08 07:55 PM
PHP in HTML Pages? ZeoFateX PHP 19 01-04-06 07:42 PM
Classified Ads skipper23 Perl 3 11-22-05 03:22 AM
Classified Ads skipper23 Perl 2 12-30-03 04:43 AM
echo foriegn html in static page fergusom Everything Java 4 11-10-03 03:35 AM


All times are GMT -5. The time now is 09:44 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.