Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Output Issue

Status
Not open for further replies.

pmcmicha

Technical User
May 25, 2000
353
I am just starting with php, but I have been unable to find a solution. I have a simple html page with php.

Code:
<html>
<head>
<style type="text/css">
    @import url(file);
</style>
<title>Page</title>
</head>
<body>
Text here.
<hr>
<?php
    echo "Hello World!";
?>
<hr>
</body>
</html>

While the echo is displayed, I am also getting the following on the page:

"; ?>

When I view the page source, the php section is highlighted in pink up to the first quote. After that, it all goes to black text.
 
Hi

pmcmicha said:
I have a simple html page with php.
That sounds bad. If you have PHP code inside, that is a PHP script. To have the PHP script executed, the file usually must have a distinct extension, typically .php . And of course, the web server must be configured to fire up the PHP interpreter for those files.
[ul]
[li]Are you requesting the file through a web server, I mean, with HTTP protocol, right ?[/li]
[li]What web server you use ?[/li]
[li]Did you installed you web server "manually" or with an "all in one" package ?[/li]
[li]By the way, what operating system it is ?[/li]
[li]Do you have PHP installed, I mean, what you get if you run [tt]php -v[/tt] from the command line ?[/li]
[/ul]

Feherke.
 
feherke,

I was under the impression that php code could be embedded in html without a problem.

1) The file is being requested through a webserver.
2) I am using a hosting service. Yebohost.
3) Unknown.
4) Unix.
5) I am unable to login to the command line, but per the hosting provider, PHP is allowed.
 
Hi

Hmm... Or just ignore me. I think that is the ugliest hosting offer I saw and finally I do not understand what they give.

Anyway. What extension has your file ? Usually it has to be .php .

But when more than one interpreter is installed, things are not so simple. They mention about PHP 4 and 5. Years ago, when PHP 3 appeared and for compatibility issues the old PHP 2 had to be kept, the usual way was to let the .php extension for the old version 2 interpreter and set up the web server to execute files with .php3 extension with the ne version 3 interpreter. If they done something similar, then you have to read their documentation.

Feherke.
 
pmcmicha said:
...
When I view the page source, the php section is highlighted in pink up to the first quote. After that, it all goes to black text.

That's the first sign that PHP is not working. You should not be able to see any PHP code, at all when you use the View Source command from within the browser.

Why, because PHP is parsed at the server. This means the server does all the PHP work, and then just outputs html to the brwoser. No PHP is ever sent to the browser unless something is wrong.


As feherke said does yore php page have a php extension?
"mypage.[red]php[/red]"

Usually pages with an html extension will not get parsed by the server for PHP, unless the server is configured to do so, and most aren't.

What do you get if you put the following in a file and upload it to your server, and then open it with your browser:

Code:
<?PHP
phpinfo();
?>
Just than, no html tags, notthing else.


If you get nothing that means PHP is not working. if you get lots of information about the PHP installation then it is working, and the cause is something else.

----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
feherke and vacunita,

Thanks for the responses, you were right in regards to the extension.
 
Glad you sorted it out.

----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top