473,772 Members | 2,272 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Noob - php works as .php but not when part of html

I'm missing something and need a push in the right direction.
If I create a php file with the following content, and call it via a
browser, it works as expected.
<?php
echo "hello world";
?>

If I embed the same thing in a simple HTML file, I get nothing.
<html>
<body>
<?php>
echo "Hello world";
?>
</body>
</html>

I'm running
Mandrake 10.0
Apache 2
PHP 4
The php_mod is loaded for Apache.
I did the install for both Apache and PHP via Mandrakes built in rpm
management system.

TIA for any tips.

Doug
Jul 17 '05 #1
21 2143
I noticed that Message-ID:
<zq************ ********@metroc astcablevision. com> from dogu contained
the following:
I'm missing something and need a push in the right direction.
If I create a php file with the following content, and call it via a
browser, it works as expected.
<?php
echo "hello world";
?>

If I embed the same thing in a simple HTML file, I get nothing.
<html>
<body>
<?php>
echo "Hello world";
?>
</body>
</html>


Unless you have configured Apache otherwise, the file must end in .php

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #2
I noticed that Message-ID: <r8************ *************** *****@4ax.com>
from Geoff Berrow contained the following:
If I embed the same thing in a simple HTML file, I get nothing.
<html>
<body>
<?php>
echo "Hello world";
?>
</body>
</html>


Unless you have configured Apache otherwise, the file must end in .php


Oops. Just noticed an erroneous '>'

try

<html>
<body>
<?php
echo "Hello world";
?>
</body>
</html>

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #3
Geoff Berrow wrote:
I noticed that Message-ID: <r8************ *************** *****@4ax.com>
from Geoff Berrow contained the following:

If I embed the same thing in a simple HTML file, I get nothing.
<html>
<body>
<?php>
echo "Hello world";
?>
</body>
</html>


Unless you have configured Apache otherwise, the file must end in .php

Oops. Just noticed an erroneous '>'

try

<html>
<body>
<?php
echo "Hello world";
?>
</body>
</html>

Thanks, but what I posted was a type - in my actual code, the <?php line
is identical to yours.

What do you mean 'unless you have configured Apache otherwise...'? I
bet that's the problem but don't know what to configure.

Any tips would be appreciated.

Doug
Jul 17 '05 #4
Even with HTML intermingled amongst the PHP code, it's still a .php
file.
rename it whatever.php.

Of course you could tell apache to parse .html files as .php, but that
would be very bad advice.

dogu <df***********@ netscape.net> wrote in message news:<zq******* *************@m etrocastcablevi sion.com>...
I'm missing something and need a push in the right direction.
If I create a php file with the following content, and call it via a
browser, it works as expected.
<?php
echo "hello world";
?>

If I embed the same thing in a simple HTML file, I get nothing.
<html>
<body>
<?php>
echo "Hello world";
?>
</body>
</html>

I'm running
Mandrake 10.0
Apache 2
PHP 4
The php_mod is loaded for Apache.
I did the install for both Apache and PHP via Mandrakes built in rpm
management system.

TIA for any tips.

Doug

Jul 17 '05 #5
Geoff Berrow wrote:
I noticed that Message-ID: <r8************ *************** *****@4ax.com>
from Geoff Berrow contained the following:

If I embed the same thing in a simple HTML file, I get nothing.
<html>
<body>
<?php>
echo "Hello world";
?>
</body>
</html>


Unless you have configured Apache otherwise, the file must end in .php

Oops. Just noticed an erroneous '>'

try

<html>
<body>
<?php
echo "Hello world";
?>
</body>
</html>

Seems my confusion was thinking you could co-mingle php and html code in
files with html extensions. If I change the extension to .php it works
like a charm!

Take care.

Doug
Jul 17 '05 #6
dogu wrote:
Geoff Berrow wrote:
I noticed that Message-ID: <r8************ *************** *****@4ax.com>
from Geoff Berrow contained the following:

If I embed the same thing in a simple HTML file, I get nothing.
<html>
<body>
<?php>
echo "Hello world";
?>
</body>
</html>
Unless you have configured Apache otherwise, the file must end in .php


Oops. Just noticed an erroneous '>'

try

<html>
<body>
<?php
echo "Hello world";
?>
</body>
</html>

Seems my confusion was thinking you could co-mingle php and html code in
files with html extensions. If I change the extension to .php it works
like a charm!

Take care.

Doug


Bet you can set up the server to treat html files as php :)
Jul 17 '05 #7
*** dogu escribió/wrote (Sun, 17 Oct 2004 10:32:42 -0400):
Seems my confusion was thinking you could co-mingle php and html code in
files with html extensions. If I change the extension to .php it works
like a charm!


There's no point in feeding *all* pages to the PHP interpreter. The *.php
extension is the way to parse only pages that contain code.
--
-+ Álvaro G. Vicario - Burgos, Spain
+- http://www.demogracia.com (la web de humor barnizada para la intemperie)
++ Las dudas informáticas recibidas por correo irán directas a la papelera
-+ I'm not a free help desk, please don't e-mail me your questions
--
Jul 17 '05 #8
Did you check your web server configuration?

In Apache on Linux, you might add:

AddType application/x-httpd-php .php .html

This will allow you to include PHP in your HTML as

<HTML>

blah blah blah...

<?php

php stuff blah blah blah

?>

</HTML>
You may have to have

AddOutputFilter INCLUDES .shtml
AddOutputFilter INCLUDES .html

added as well, but don't have the time to test. These turn on SSI's on
your pages, but I don't know if they affect embedded PHP or not. At
any rate I have both on my server and they work.

-DG-

dogu wrote:
Geoff Berrow wrote:
I noticed that Message-ID: <r8************ *************** *****@4ax.com>
from Geoff Berrow contained the following:

If I embed the same thing in a simple HTML file, I get nothing.
<html>
<body>
<?php>
echo "Hello world";
?>
</body>
</html>
Unless you have configured Apache otherwise, the file must end in .php


Oops. Just noticed an erroneous '>'

try

<html>
<body>
<?php
echo "Hello world";
?>
</body>
</html>

Seems my confusion was thinking you could co-mingle php and html code in
files with html extensions. If I change the extension to .php it works
like a charm!

Take care.

Doug


Jul 17 '05 #9
Data Goob wrote:
Did you check your web server configuration?

In Apache on Linux, you might add:

AddType application/x-httpd-php .php .html


You probably want to put this in a .htaccess, so that it is NOT server-wide.
Jul 17 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1947
by: Dave Williams | last post by:
First off...total noob to VB. So far have learned a lot in 1.5 days and feel fairly comfortable at throwing screens up. However, I want to start writing forms that revolve around an access database. From what I have read to date it looks like VB can only display 1 record at a time. I suspect this is not the case. How easy is it to display 10 records at a time (in a table format) that can be scrolled up and down ? When the current...
1
1808
by: davestrike | last post by:
I am a noob to sql and asp programming. I am working on a db for the gaming squad I am a member of. One of the pages I created is a roster list of all the squad members. Part of this roster is listing each member's email address. What several people have asked of me is to make it so the email addresses can be clicked on to open their email programs, just as html allows the mailto function to work. Here is a copy of the coding I am...
8
2092
by: Rich Grise | last post by:
I think I've finally found a tutorial that can get me started: http://www.zib.de/Visual/people/mueller/Course/Tutorial/tutorial.html and I've been lurking for awhile as well. What happened is, I've been playing with Qt in KDE on a Slackware 10.0 system, and following their cookbook exercises, and everything's working, and I have no clue what the code is doing, i.e.. how do I connect my brain to the ascii in the files to the stuff on...
4
1717
by: shumaker | last post by:
I'm wondering how/why this query works. Trying to get my head wrapped around SQL. Basically the Query deletes from the Import table all records that are already in FooStrings so that when I do an insert from the FooStringsImport table into the FooStrings table, then I won't get primary key violations. DELETE FROM FooStringsImport WHERE EXISTS (SELECT * FROM FooStrings WHERE FooStringsImport.FooKey = FooStrings.FooKey)
42
3461
by: Holger | last post by:
Hi guys Tried searching for a solution to this, but the error message is so generic, that I could not get any meaningfull results. Anyways - errormessage: ---------------------------------------------------- TypeError: addFile() takes exactly 1 argument (2 given) ----------------------------------------------------
0
1485
by: AndyW | last post by:
Hey folks. I am trying to get a soap wsdl service working and have a bit of a noob php programming question for it. I'm using PHP 5.x btw. I have written a soap server that contains a single method in the form: SayHelloWorld( $name ) { return "Hello " .$name; };
6
1987
by: Paulchen | last post by:
Hello, I have found a perl script and need to "translate" this to PHP. I try to do it step by step and the first part of it is this function (the whole script is found at http://nonsense.sourceforge.net/): ### Load and parse a datafile, slurping the contents into the %pool hash sub LoadDataFile { my $file = shift; $file = SafeFile( $file ) if $cgi_mode; open IN, $file or die "Error opening $file... $!\n"; local $/ = ''; ...
2
1039
by: kj | last post by:
I'm a Python noob, and haven't yet figured out my way around the Python documentation. For example, suppose I learn about some great module foo.bar.baz, and when I run the python interpreter and type "import foo.bar.baz", lo and behold, it is already installed on our system, which means that (knowing that our system is pretty bare-bones as far as python goes) most likely foo.bar.baz is part of the standard python installation.
1
2533
by: Fluffy654 | last post by:
First off I am a complete noob when it comes to doing anything with servers. I'm just beginning to learn today because I need to start adding SSI to my websites. I apologise in advance if I am making a really obvious mistake. To test this, I have successfully installed apache and have read the official documentation on how to get SSI functionality working. Unfortunately, I can't get it to work at all. After reading tons of threads on this...
0
9620
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10104
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10038
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9912
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8934
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7460
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5354
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5482
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2850
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.