473,395 Members | 1,556 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Browser do not understand php?

Sorry for the stupid question. I created *.html file with the
following contents.

<html>
<head>
<title>Example</title>
</head>
<body>
<?php
echo "Hi, I'm a PHP script!";
?>
</body>
</html>

Then I tried to read this file by Netscape and only what I could see
was white background. Can you tell me why? I use Linux Suse. Do I need
to instal something to be able read mentioned *html file?
Thank you.
Jul 17 '05 #1
6 2100

"Kurda Yon" <ku******@yahoo.com> wrote in message
news:f8**************************@posting.google.c om...
Sorry for the stupid question. I created *.html file with the
following contents.

<html>
<head>
<title>Example</title>
</head>
<body>
<?php
echo "Hi, I'm a PHP script!";
?>
</body>
</html>

Then I tried to read this file by Netscape and only what I could see
was white background. Can you tell me why? I use Linux Suse. Do I need
to instal something to be able read mentioned *html file?
Thank you.


PHP won't execute for a .html file, since Apache won't know to pass the file
to PHP for parsing, so it comes back as empty (counts as an unsupported tag
as far as the browser is concerned). But hey, this could be the tip of the
iceberg.

Where did you put the file? Is Apache (or something else) running? On port
80? What happens if you connect via telnet? Did you spell the page right?
Did View Source in the browser show anything? Does the title you put in
('Example') appear in Nutscrape's title bar? Are there any responses in the
/var/log/httpd/* files?

Garp
Jul 17 '05 #2
On 19 May 2004 11:31:04 -0700, Kurda Yon hath writ:
Sorry for the stupid question. I created *.html file with the
following contents.

<html>
<head>
<title>Example</title>
</head>
<body>
<?php
echo "Hi, I'm a PHP script!";
?>
</body>
</html>

Then I tried to read this file by Netscape and only what I could see
was white background. Can you tell me why? I use Linux Suse. Do I need
to instal something to be able read mentioned *html file?
Thank you.


"...I tried to read this file by Netscape ..." ??
Do you mean:
file://path/to/your/Example.php

If so, then Netscape will do what it's told: It will display the file.
You need to ask a PHP-enabled _server_ to serve up (and processs) this
file to see the HTML and PHP-generated text:

http://url/for/the/Example.php

Anyway, it should _not_ be a "*.html" file as you stated. It should
be a xxx.php file, so that the server is prepared to invoke the PHP
interpreter when it encounters the "<?php ...." entries.
If you use xxx.html, or are making the request of a web server that
is _not_ PHP-enabled, your "<?php ...." entries will be treated as
HTML comments, and _nothing_ of that section of the file will be
sent down to your browser.

HTH
Jonesy
--
| Marvin L Jones | jonz | W3DHJ | OS/2
| Gunnison, Colorado | @ | Jonesy | linux __
| 7,703' -- 2,345m | config.com | DM68mn SK
Jul 17 '05 #3
Kurda Yon wrote:

Sorry for the stupid question. I created *.html file with the
following contents.

<html>
<head>
<title>Example</title>
</head>
<body>
<?php
echo "Hi, I'm a PHP script!";
?>
</body>
</html>

Then I tried to read this file by Netscape and only what I could see
was white background. Can you tell me why? I use Linux Suse. Do I need
to instal something to be able read mentioned *html file?
Thank you.

PHP is a server-side technology, your browser has little to do with it.
Where did you create this file? If on your computer at home, do you have
a server running that can execute PHP? If on a web site, does your ISP
provide PHP? Does it require a special extension? Many only parse pages
that have a .php, .php3, .php4 or similar extension, although that is
configurable.

I think you need to retrench and read up on PHP. It is not another form
of javascript.

Go here:

http://php.net


Brian Rodenborn
Jul 17 '05 #4
ku******@yahoo.com (Kurda Yon) writes:
Sorry for the stupid question. I created *.html file with the
following contents.

<html>
<head>
<title>Example</title>
</head>
<body>
<?php
echo "Hi, I'm a PHP script!";
?>
</body>
</html>


You have to do the following to use see the effects of PHP in a
browser:

1) Install the file on a webserver. If the file is placed on the
local filesystem, and you access directly with your browser, then
nothing special will happen --- the browser will read the PHP code
as it is. It is the webserver job (with the help of PHP) to
translate the code into something, typically HTML.

2) Name the file so that your webserver will understand that this is a
PHP script and that it will have to run the script through PHP
before sending it back to the browser. The typical extension would
be '.php'.

Since you're using Linux I assume you will be using Apache as well
(an excellent combination). You'll have to make sure that your
httpd.conf contains the following directive:

AddType application/x-httpd-php .php

My configuration file is stored as /etc/apache/httpd.conf, but your
might be stored elsewere, or you might be able to use a
configuration tool from within SuSE. Or perhaps it will just work
when you give your scritp the '.php' extension.

--
Martin Geisler My GnuPG Key: 0xF7F6B57B

PHP EXIF Library | PhpWeather | PhpShell
http://pel.sf.net/ | http://phpweather.net/ | http://gimpster.com/
Read/write EXIF data | Show current weather | A shell in a browser
Jul 17 '05 #5
OK. Thank you very much. Now I understand what was my problem:
1. The file was placed on the local file system.
2. Apache (or something else) is not running.
3. File was named *.html (not *.php)
Now I will change all this thinks and try again.
Jul 17 '05 #6
I made an .htaccess file and uploaded it to my server
with the lines

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

that way my php scripts work with the .wml, html and htm files... i'm
planning to add another 2 lines later, but i've yet to observe that these
below work

AddType application/x-httpd-php .xhtml
AddType application/x-httpd-php .xml

HOW I DID IT ---
1. open notepad and type those lines above
2. name it htaccess.txt
3. upload to the server directory where you want php to operate... if you
have the following folder hierarchy, dir1/dir2/dir3/etc if you upload to
dir2, just upload ONCE to the folder where you want php to start operating,
and php will work with all succeeding folders.
4. rename the file to .htaccess don't forget the period before htaccess

my server has apache

so you really don't need the tags to be phtml or php

I DID THIS BECAUSE I don't want people to know i'm using php.

also i also have a problem with php i couldn't figure out... its the one
with the heading "help me please i need a magic word / function" can you
guys read that and answer back? thanks

"Kurda Yon" <ku******@yahoo.com> wrote in message
news:f8**************************@posting.google.c om...
Sorry for the stupid question. I created *.html file with the
following contents.

<html>
<head>
<title>Example</title>
</head>
<body>
<?php
echo "Hi, I'm a PHP script!";
?>
</body>
</html>

Then I tried to read this file by Netscape and only what I could see
was white background. Can you tell me why? I use Linux Suse. Do I need
to instal something to be able read mentioned *html file?
Thank you.

Jul 17 '05 #7

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

Similar topics

5
by: DU | last post by:
Hi! I really need to understand what is so-called browser error correction mechanisms. Can you explain this? I read somewhere (and I no longer can find where I read that) that browsers try to...
17
by: lawrence | last post by:
How is it possible that the question "How do I detect which browser the user has" is missing from this FAQ: http://www.faqts.com/knowledge_base/index.phtml/fid/125 and is only here on this...
5
by: David Baker | last post by:
Hi all I am very new to ASP.Net. I am trying to create a sniffer for our program. We want our users to click our sniffer and hopefully the sniffer will check their computer against our...
1
by: Lance | last post by:
Hi, Is there a way to tell if a browser is currently capable of javascript? ie if the user has disabled it or not? I understand that the Request.Browser.JavaScript property will tell if a...
5
by: Bill Cohagan | last post by:
I'm having some serious difficulties with my ASP.Net 2.0 app rendering in Safari 2.0.3. The most immediate problem is that the menu control doesn't seem to work at all, particularly the use of...
5
by: fjanon | last post by:
Hi, I went through the HTML spec without finding the description of what the browsers behavior should/must be regarding tags or attributes they don't understand. I did a quick experiment like...
7
by: Danny | last post by:
Hello: I would like to develop a browser extension, or whatever such a thing is classified as, that would allow a user of IE6, and possibly IE7, to switch between a live and development page. ...
246
by: Chris F.A. Johnson | last post by:
I have posted a quick survey at <http://cfaj.freeshell.org/testing/width.shtml>. There's only one question: select the widest line that fits in your normal browser window. Your assistance is...
10
by: Conrad Lender | last post by:
In a recent thread in this group, I said that in some cases object detection and feature tests weren't sufficient in the development of cross-browser applications, and that there were situations...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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...

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.