Embed PHP in HTML

 
Post new topic   Reply to topic    Aprelium Forum Index -> PHP
View previous topic :: View next topic  
Author Message
tattooedpierre
-


Joined: 02 Sep 2003
Posts: 2
Location: Glasgow

PostPosted: Tue Oct 28, 2003 1:37 pm    Post subject: Embed PHP in HTML Reply with quote

Hi,

I know this has already been discussed previously. However, the solution given (changing CGI Interpreters extensions) doesnt seem to work for me.. when i add htm as a vaild PHP extension, my site no longer loads and returns only a Error 200.

I'm simply trying to include a tiny PHP counter on my index.htm page.

The added code is simply: include("counter.php")

I have tested the server, and the problem only occurs when i modify the CGI interpreter to allow htm files to use PHP... :(

Any ideas?

PS - I do have PHP/Perl/mySQL installed etc. Before you ask :wink:
_________________
.: TattooedPierre :.
Back to top View user's profile Send private message
aprelium
-


Joined: 22 Mar 2002
Posts: 6800

PostPosted: Wed Oct 29, 2003 12:44 am    Post subject: Re: Embed PHP in HTML Reply with quote

tattooedpierre,

It seems that there is a problem with the page where you've embedded the PHP code. Can you please post the page source code here for verification?
_________________
Support Team
Aprelium - http://www.aprelium.com
Back to top View user's profile Send private message Send e-mail
os17fan
-


Joined: 21 Mar 2003
Posts: 531
Location: USA

PostPosted: Wed Oct 29, 2003 2:05 am    Post subject: Reply with quote

I know why you get the error 200 , when embeding HTML in a PHP script , you must do it a different way , you can't just type a html link and expect to get your PHP code to work

<a href="URL">link text</a>

The proper way to type html as a link in a PHP script

<a href=\"URL\">link text</a>

The thing is this , if you type it regularly , the PHP script will think its exacuting PHP varibals and their for you have to add \ to over come this , they have some PHP books at Barnes & Noble for less than $20. I got the one by Larry Ullman

Quick tip!

When your adding fonts and images , you can just do this , right after you get to the = sign for a image or any type of html , put a \ , so it will be =\

When you have the "" , just put a =\"\" , you should get what im saying right now if you know html. Here's some examples

-------------------------------------------------------------+
Image: <img src=\"your_image.jpg\">

Font color & size: <font color=\"blue\" font size=\"4\">

Background color: <body bgcolor=\"color\">
-------------------------------------------------------------+

Do you get what im saying now , its very simple.

I just started PHP programming! lol :D
_________________
This web server is the best !
Back to top View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
tattooedpierre
-


Joined: 02 Sep 2003
Posts: 2
Location: Glasgow

PostPosted: Thu Oct 30, 2003 3:38 pm    Post subject: Reply with quote

Hey, thanks for your reply. However, I'm not trying to embed HTML into PHP, rather PHP into HTML :wink: .. not sure though if this makes a difference. In any case, here is my current code:
--------------------------------------------------------------------------
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>:: sweetsurrender ::</title>
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body>
<table style="width:100%;">
<tr>
<td align="center">
<img src="/images/chinaman.gif" style="border:1px solid black;margin-bottom:10px;margin-top:10px;"/>
<img src="/images/logo.gif" alt="logo sweetsurrender" style="border:1px solid black;margin-bottom:10px;margin-top:10px;"/>
<table class="main">
<tr>
<td style="width:150px;border-right:1px solid black;" align="center" valign="top">
<table style="width:1px;margin:15px 15px 15px 15px;">
<tr>
<td style="border:1px solid black;">
<div style="text-align:center;font-weight:bold;margin-top:5px;margin-bottom:7px;">Menu</div>
<div style="text-align:left;margin:0px 6px 10px 2px;white-space:nowrap;font-size:12px;line-height:135%;">
<img src="images/bullets/arrow_left.gif" align=left style="border:none;"/>&nbsp;<a href="index.htm" title="Homepage" style="font-weight:bold;">Home</a><br />
<img src="images/bullets/arrow_left.gif" align=left style="border:none;"/>&nbsp;<a href="aboutme.htm" title="All About Me">About Me</a><br />
<img src="images/bullets/arrow_left.gif" align=left style="border:none;"/>&nbsp;<a href="/gallery/" title="Online photo gallery">My Pictures</a><br />
<img src="images/bullets/arrow_left.gif" align=left style="border:none;"/>&nbsp;<a href="games.htm" title="Simple online games">Games</a><br />
<img src="images/bullets/arrow_left.gif" align=left style="border:none;"/>&nbsp;<a href="chat.htm" title="sweetsurrender chat rooms">Chat</a><br />
<img src="images/bullets/arrow_left.gif" align=left style="border:none;"/>&nbsp;<a href="links.htm" title="Links to other quality sites">Links</a></div>

</td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td style="border:1px solid black;" align="center">
<div style="text-align:center;font-weight:bold;margin-top:5px;margin-bottom:5px;">
Guestbook<br />
<span style="font-weight:normal;">
</span>
</div>
<div style="margin:0px 5px 0px 5px;">
<form action="http://tryin2.servebeer.com/hdguestbook/" method="post">
<div>
<input type="hidden" name="ID" value="15190"/>
<div style="margin-bottom:5px;">
</div>
<input type="submit" value="Sign Me"/>
<br><br>
Visitors:
<?php



function hitcounter()

{

$AppStart='Sept 12 2002';

$hitsfile = './counter/counter.txt';



while($f==0)

{

$hits = file($hitsfile);

if($hits['0']!=0)

{

$hits = $hits['0'] + 1;

$fp = fopen($hitsfile, "w");

fwrite($fp, $hits);

return number_format($hits).' hits since

'.$AppStart;

$f=1;

}

}

}

echo hitcounter();

?>

</div>
</form>
</div>
</td>
</tr>
</table>
</td>
<td style="width:550px;vertical-align:top;">
<div style="margin:10px">
<div class='titre'>:: news</div>
<div class='texte'>Added the holiday pics.. should be getting some prints quite soon.
</td>
</tr>
<tr>
<td colspan="2" style="border-top:1px solid black;text-align:center;font-size:10px;color:gray;">
copright (c) 2003 - sweetsurrender, http://tryin2.servebeer.com<br>
you shouldn't be reading this part. it's not interesting.
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
--------------------------------------------------------------------------
Right, I apologise in advance if this seems sloppy at all. I must admit that it was not myself that coded the bulk of the HTML.

Any help is much appreciated.
_________________
.: TattooedPierre :.
Back to top View user's profile Send private message
aprelium
-


Joined: 22 Mar 2002
Posts: 6800

PostPosted: Fri Oct 31, 2003 4:43 pm    Post subject: Reply with quote

It seems that the first line

Code:
<?xml version="1.0" encoding="ISO-8859-1"?>


drives PHP crazy. So remove it and retry.
_________________
Support Team
Aprelium - http://www.aprelium.com
Back to top View user's profile Send private message Send e-mail
WhiteDevil
-


Joined: 07 Oct 2002
Posts: 74
Location: United Kingdom

PostPosted: Wed Nov 26, 2003 9:32 pm    Post subject: Reply with quote

Also im just going to assume that you have saved the file as a .php and not a .html/.htm :D
_________________
Back to top View user's profile Send private message Send e-mail Visit poster's website AIM Address MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> PHP All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group