Welcome to HostingForumz.com!
FAQFAQ      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

embed PHP in HTML file

 
   Web Hosting Problem Solving Community! (Home) -> Apache RSS
Next:  Dead Apache  
Author Message
Paul Pedersen

External


Since: Jan 10, 2008
Posts: 15



(Msg. 1) Posted: Mon Feb 11, 2008 9:17 am
Post subject: embed PHP in HTML file
Archived from groups: alt>apache>configuration (more info?)

I have the following HTML file:

(test.html)

<HTML>

This is in the HTML section.

<?php
$v1 = "<BR>And this is ";
$v2 = "in the PHP section.";
echo $v1 . $v2;
?>

</HTML>


When I access that file with my local copy of Apache 2.2.8, I get this:

This is in the HTML section.
And this is in the PHP section.


But when I load test.html from my shared web hosting account running Apache
1.3.3, I get this:

This is in the HTML section. And this is "; $v2 = "in the PHP section.";
echo $v1 .$v2; ?>


My local server does what I expect, but the shared host server just passes
on (some of) the php code. If I change the name of the file from test.html
to test.php, it works.


Why does an html extension work on my local server but not on the remote
one? Is it because of the older version of Apache? Or is there a setting
that must be changed?

 >> Stay informed about: embed PHP in HTML file 
Back to top
Login to vote
Lars

External


Since: Feb 10, 2008
Posts: 4



(Msg. 2) Posted: Mon Feb 11, 2008 5:11 pm
Post subject: Re: embed PHP in HTML file [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Hi

Does you shared Apache server load the right PHP in the httpd.conf file?
Doesn't seam that way.

As a suggestion I would recoment you to split the document int one PHP and
one HTML file.


file phpfile.php
<?php

$v1 = "<BR>And this is ";
$v2 = "in the PHP section.";

// Note that I changed to printf in steat of echo
printf("%s %s\n", $v1 . $v2 );

?>


htm file
<HTML>

This is in the HTML section.

<?php
#nclude "phpfile.php"
?>





Lars


"Paul Pedersen" <nospam.RemoveThis@no.spam> skrev i meddelandet
news:we-dndIWpLOnHi3anZ2dnUVZ_jednZ2d@comcast.com...
>I have the following HTML file:
>
> (test.html)
>
> <HTML>
>
> This is in the HTML section.
>
> <?php
> $v1 = "<BR>And this is ";
> $v2 = "in the PHP section.";
> echo $v1 . $v2;
> ?>
>
> </HTML>
>
>
> When I access that file with my local copy of Apache 2.2.8, I get this:
>
> This is in the HTML section.
> And this is in the PHP section.
>
>
> But when I load test.html from my shared web hosting account running
> Apache 1.3.3, I get this:
>
> This is in the HTML section. And this is "; $v2 = "in the PHP section.";
> echo $v1 .$v2; ?>
>
>
> My local server does what I expect, but the shared host server just passes
> on (some of) the php code. If I change the name of the file from test.html
> to test.php, it works.
>
>
> Why does an html extension work on my local server but not on the remote
> one? Is it because of the older version of Apache? Or is there a setting
> that must be changed?
>
>
>
>
>
>

 >> Stay informed about: embed PHP in HTML file 
Back to top
Login to vote
Paul Pedersen

External


Since: Jan 10, 2008
Posts: 15



(Msg. 3) Posted: Mon Feb 11, 2008 5:11 pm
Post subject: Re: embed PHP in HTML file [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Thank you for your response.

No, that does not work. (I had to tweak your example a little.)

The same thing happens - it works fine on my local 2.2.8 Apache, but the
remote 1.3.3 Apache simply returns the <?php ... ?> section literally:

<HTML>

This is in the HTML section.

<?php
include("phpfile.php");
?>

</HTML>


"Lars" <jon.doe.RemoveThis@xxxxxxxxxxxxxxxxxx.xxx> wrote in message
news:xG%rj.3749$R_4.2531@newsb.telia.net...
> Hi
>
> Does you shared Apache server load the right PHP in the httpd.conf file?
> Doesn't seam that way.
>
> As a suggestion I would recoment you to split the document int one PHP and
> one HTML file.
>
>
> file phpfile.php
> <?php
>
> $v1 = "<BR>And this is ";
> $v2 = "in the PHP section.";
>
> // Note that I changed to printf in steat of echo
> printf("%s %s\n", $v1 . $v2 );
>
> ?>
>
>
> htm file
> <HTML>
>
> This is in the HTML section.
>
> <?php
> #nclude "phpfile.php"
> ?>
>
>
>
>
>
> Lars
>
>
> "Paul Pedersen" <nospam.RemoveThis@no.spam> skrev i meddelandet
> news:we-dndIWpLOnHi3anZ2dnUVZ_jednZ2d@comcast.com...
>>I have the following HTML file:
>>
>> (test.html)
>>
>> <HTML>
>>
>> This is in the HTML section.
>>
>> <?php
>> $v1 = "<BR>And this is ";
>> $v2 = "in the PHP section.";
>> echo $v1 . $v2;
>> ?>
>>
>> </HTML>
>>
>>
>> When I access that file with my local copy of Apache 2.2.8, I get this:
>>
>> This is in the HTML section.
>> And this is in the PHP section.
>>
>>
>> But when I load test.html from my shared web hosting account running
>> Apache 1.3.3, I get this:
>>
>> This is in the HTML section. And this is "; $v2 = "in the PHP section.";
>> echo $v1 .$v2; ?>
>>
>>
>> My local server does what I expect, but the shared host server just
>> passes on (some of) the php code. If I change the name of the file from
>> test.html to test.php, it works.
>>
>>
>> Why does an html extension work on my local server but not on the remote
>> one? Is it because of the older version of Apache? Or is there a setting
>> that must be changed?
>>
>>
>>
>>
>>
>>
>
>
 >> Stay informed about: embed PHP in HTML file 
Back to top
Login to vote
Lars

External


Since: Feb 10, 2008
Posts: 4



(Msg. 4) Posted: Mon Feb 11, 2008 8:05 pm
Post subject: Re: embed PHP in HTML file [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

"Paul Pedersen" <nospam.DeleteThis@no.spam> skrev i meddelandet
news:gbudndc9QfYLDS3anZ2dnUVZ_o6knZ2d@comcast.com...
> Thank you for your response.
>
> No, that does not work. (I had to tweak your example a little.)
>
> The same thing happens - it works fine on my local 2.2.8 Apache, but the
> remote 1.3.3 Apache simply returns the <?php ... ?> section literally:

Does Apache 1.3.3 support inline PHP scripting in HTML files.

Try moving the script to another file and see what happens.

Or try this

Write a file that exactly as this. Save it as phpinfo.php then upload the
file and access it. You get lots of information about you server this way.

<?php
phpinfo();
?>

Outputs a large amount of information about the current state of PHP. This
includes information about PHP compilation options and extensions, the PHP
version, server information and environment (if compiled as a module), the
PHP environment, OS version information, paths, master and local values of
configuration options, HTTP headers, and the PHP License.

Lars

>
> <HTML>
>
> This is in the HTML section.
>
> <?php
> include("phpfile.php");
> ?>
>
> </HTML>
>
>
> "Lars" <jon.doe.DeleteThis@xxxxxxxxxxxxxxxxxx.xxx> wrote in message
> news:xG%rj.3749$R_4.2531@newsb.telia.net...
>> Hi
>>
>> Does you shared Apache server load the right PHP in the httpd.conf file?
>> Doesn't seam that way.
>>
>> As a suggestion I would recoment you to split the document int one PHP
>> and one HTML file.
>>
>>
>> file phpfile.php
>> <?php
>>
>> $v1 = "<BR>And this is ";
>> $v2 = "in the PHP section.";
>>
>> // Note that I changed to printf in steat of echo
>> printf("%s %s\n", $v1 . $v2 );
>>
>> ?>
>>
>>
>> htm file
>> <HTML>
>>
>> This is in the HTML section.
>>
>> <?php
>> #nclude "phpfile.php"
>> ?>
>>
>>
>>
>>
>>
>> Lars
>>
>>
>> "Paul Pedersen" <nospam.DeleteThis@no.spam> skrev i meddelandet
>> news:we-dndIWpLOnHi3anZ2dnUVZ_jednZ2d@comcast.com...
>>>I have the following HTML file:
>>>
>>> (test.html)
>>>
>>> <HTML>
>>>
>>> This is in the HTML section.
>>>
>>> <?php
>>> $v1 = "<BR>And this is ";
>>> $v2 = "in the PHP section.";
>>> echo $v1 . $v2;
>>> ?>
>>>
>>> </HTML>
>>>
>>>
>>> When I access that file with my local copy of Apache 2.2.8, I get this:
>>>
>>> This is in the HTML section.
>>> And this is in the PHP section.
>>>
>>>
>>> But when I load test.html from my shared web hosting account running
>>> Apache 1.3.3, I get this:
>>>
>>> This is in the HTML section. And this is "; $v2 = "in the PHP section.";
>>> echo $v1 .$v2; ?>
>>>
>>>
>>> My local server does what I expect, but the shared host server just
>>> passes on (some of) the php code. If I change the name of the file from
>>> test.html to test.php, it works.
>>>
>>>
>>> Why does an html extension work on my local server but not on the remote
>>> one? Is it because of the older version of Apache? Or is there a setting
>>> that must be changed?
>>>
>>>
>>>
>>>
>>>
>>>
>>
>>
>
>
 >> Stay informed about: embed PHP in HTML file 
Back to top
Login to vote
Paul Pedersen

External


Since: Jan 10, 2008
Posts: 15



(Msg. 5) Posted: Mon Feb 11, 2008 8:05 pm
Post subject: Re: embed PHP in HTML file [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

"Lars" <jon.doe DeleteThis @xxxxxxxxxxxxxxxxxx.xxx> wrote in message
news:H14sj.3756$R_4.2795@newsb.telia.net...
>
> Does Apache 1.3.3 support inline PHP scripting in HTML files.

Yes, that was my original question. Or is there a setting that allows that?



> <?php
> phpinfo();
> ?>

I've done that, but being new to web programming, I don't know what most of
that stuff means. I didn't see anything relevant that was obvious to me.


Thanks anyway. I guess I just won't try to embed php code in html files,
because that doesn't seem to work reliably.
 >> Stay informed about: embed PHP in HTML file 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
php file not getting variables from html file - my setup: win 98 SE; Apache 2.0; php 4; 2 files: welcome1.html & welcome1.php welcome1.html file contents: <html> <head> <title></title> </head> <body> <FORM ACTION="welcome1.php" METHOD=GET> F...

Can't run CGI/perl script from html file - I have created a perl script and put it in my cgi-bin dir and given read/execute permissions (755) for the dir and file, but my html form still gets a not found error (404) when trying to run the script: Form line: "<FORM ACTION="/cgi-bin/t...

pass data to .html file? - Hello, I noticed some sites can pass data to a .html file. Maybe it is not a real .html but from the URL it looks like this: http://www.a_site.com/a_document.html?p=1234 I am curiouse how can it like this...maybe in apache httpd.conf there is somethin...

HEADER.html file blank when bigger than 255 bytes - Hi, We've got Apache 2.2.4 running on a Solaris 10 box and in the root home directory of the site we've got a HEADER.html for displaying content above the directory listing. We can get this to work OK as long as the file HEADER.html doesn't go over 255...

http-config File => html & perl files in same folder + sub.. - Hello, I ran my Apache 2.0.48 Server on my local PC under Win98. Apache is installed as C:/Apache/Apache2/.. Perl (Active State 5.8) is installed as c:/Perl/... My HTML docs are under C:/EigeneDateien/EigeneWebs/ I want to install PERL scripts withi...
   Web Hosting Problem Solving Community! (Home) -> Apache All times are: Pacific Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can 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



[ Contact us | Terms of Service/Privacy Policy ]