Welcome to WebmasterWorld Guest from 54.196.244.186

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

<?php phpinfo(); ?> returns blank when embedded in .html

     
12:54 pm on Aug 3, 2010 (gmt 0)

Junior Member

10+ Year Member

joined:June 27, 2004
posts: 98
votes: 0


Hello,

I am configuring a new server with Lighttpd, PHP5 & mysql as on this page:[howtoforge.com ]

Well, i am noob on those things, the problem is that when I test php via a simple index.php page with <?php phpinfo(); ?> in it, everything's ok. But, When I embed that into an .html file as shown below, the page returns blank.

<html>
<head>
<title>PHP Test</title>
</head>
<body>
<?php phpinfo(); ?>
</body>
</html>

what may be the reason for that? I think something is wrong.

p.s.: Using mysql_secure_installation, i have disabled remote connections. What is this for? On 'CentOS perfect setup' pages, everyone recommends setting:

mysqladmin -h server.example.com -u root password yourrootpassword

do I really have to set this?
2:18 pm on Aug 3, 2010 (gmt 0)

Senior Member

WebmasterWorld Senior Member 5+ Year Member

joined:Feb 22, 2009
posts:1396
votes: 0


Hi there teasers,

When I embed that into an .html file as shown below, the page returns blank.


It will, you need the file type to be .php otherwise the parser won't be invoked to do it's job - you can however do something with apache that tells it to use the php parser on .html files too, though I haven't done this before.

Cheers,
MRb
5:37 pm on Aug 3, 2010 (gmt 0)

Junior Member

10+ Year Member

joined:June 27, 2004
posts:98
votes: 0


thanks matthew..
So I think the above example, which puts php into html is a wrong example as performing a test -- unless 'do something with apache that tells it to use the php parser on .html files too' as you said.
7:08 pm on Aug 3, 2010 (gmt 0)

Senior Member

WebmasterWorld Senior Member rocknbil is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Nov 28, 2004
posts:7999
votes: 0


No, you can put PHP inline in HTML - you must simply name the file with a PHP extension. test.html = test.php.
7:35 am on Aug 4, 2010 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Apr 24, 2005
posts:697
votes: 0


You can use .htaccess file in the directory to tell apache about that, its a 1 line command.


AddType application/x-httpd-php .html
9:08 am on Aug 4, 2010 (gmt 0)

Junior Member

10+ Year Member

joined:June 27, 2004
posts:98
votes: 0


and.. if the server is Lighttpd? Same?
thank you
11:45 am on Aug 5, 2010 (gmt 0)

Administrator

WebmasterWorld Administrator coopster is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:July 31, 2003
posts:12533
votes: 0


You'll want to get familiar with the configuration directives [redmine.lighttpd.net] for that http server.