Current location: Hot Scripts Forums » General Web Coding » HTML/XHTML/XML » Putting PHP into a HTML page?


Putting PHP into a HTML page?

Reply
  #1 (permalink)  
Old 01-11-05, 06:01 PM
PigeonHead PigeonHead is offline
New Member
 
Join Date: Jan 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Putting PHP into a HTML page?

I have a web page made in html. I also have a couple of php scripts that I want to put into the html page in certain places. Whenever I copy them in in Frontpage or Dreamweaver, it displays the php as txt and doesn't display what the php is coded to do.

How do I put a php script into my html page and get it to work?
Reply With Quote
  #2 (permalink)  
Old 01-11-05, 06:16 PM
the_mole001's Avatar
the_mole001 the_mole001 is offline
Newbie Coder
 
Join Date: Feb 2004
Location: Australia
Posts: 96
Thanks: 0
Thanked 0 Times in 0 Posts
Hello There,

First things first, have you put the "<?php" and "?>" tags at the start and end of the code respectively? The other thing is, even though you may be classing it as a html page with php, however it is read as a php page with html, so you have to save the page as a .php extension. Hopefully your code will now work.
__________________
Current Project: GGAC Website
Project Link: http://peter.5gigs.com/
Reply With Quote
  #3 (permalink)  
Old 01-11-05, 06:20 PM
PigeonHead PigeonHead is offline
New Member
 
Join Date: Jan 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
But what about the way the editors display it as text? Is that just because it hasn't been saved as php?

And, how do I get it to display as the first page when you go on my site (just like index.html)? I get an error when I just put index.php

Last edited by PigeonHead; 01-11-05 at 06:24 PM.
Reply With Quote
  #4 (permalink)  
Old 01-11-05, 07:13 PM
bugalyzer bugalyzer is offline
Newbie Coder
 
Join Date: Apr 2004
Posts: 86
Thanks: 0
Thanked 0 Times in 0 Posts
scripts

Some editors will display the text (you should refer to it as your source PHP code) or the output of it (if you have an emulator built into it)... You really need to get use to viewing your PHP source code and understand in your head how it displays..

To get an index.php page to serve up instead of an index.html page - just remove the index.html page. If this doesn't work then you need to configure your webserver to use index.php as an index page.

http://buildacom.com
Reply With Quote
  #5 (permalink)  
Old 01-23-05, 10:14 PM
Patiek Patiek is offline
Wannabe Coder
 
Join Date: Nov 2003
Posts: 165
Thanks: 0
Thanked 0 Times in 0 Posts
WYSIWYG (What you see is what you get) editors are tricky because they do not place the text that you paste into your page as that text but rather an html representation of that text.

Therefore a code like:

Code:
<php 
echo "Hello World!";
?>
Ends up really becoming:
Code:
&lt;php <br>
echo &quot;Hello World!&quot;;<br>
?&gt;
Unforunately, the above will not print hello world as expected . In order to make the editor strict, (and I am referring to dreamweaver), you have to right-click where you want the code to be inserted, click insert HTML.... and replace what pops up (<>) with the PHP code that you have (Make sure it has <? and ?> tags to begin and end it).

Then press enter and the box will disappear and it will look like you haven't done anything. However, if you open up the page in a text editor or view the code in dreamweaver, you will see that your PHP is in fact there.
Reply With Quote
  #6 (permalink)  
Old 01-24-05, 02:22 PM
homocidal rabbi homocidal rabbi is offline
New Member
 
Join Date: Dec 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Well I am actually setting up a website at the moment that is running php in the background but uses html for everything else. All that was required was to save the files as shtml files instead. As long as you have everything put in right this should work, it did for me anyway.
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
html tutoral thefrtman HTML/XHTML/XML 5 04-27-09 10:25 AM
Classified Ads skipper23 Perl 3 11-22-05 02:22 AM
Mouseover with Single PHP page rjwebgraphix PHP 7 09-16-04 05:15 PM
php on a html page Bonzo PHP 9 02-06-04 10:40 PM
Classified Ads skipper23 Perl 2 12-30-03 03:43 AM


All times are GMT -5. The time now is 08:42 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.