PDA

View Full Version : [ubuntu] php problem



chettiyar
July 12th, 2009, 01:07 PM
My php codes in html file are not processed. All the items inside <html> and </html> except those within <php and ?> are processed. No error message also shown. Can anybody help???
I get the following error message when I try to restart apache.
apache2: Could not reliably determine the server's fully qualified domain name, using XXX.X.X.X for ServerName (in the place of X digits appear). Is this the reason for php problem????

credobyte
July 12th, 2009, 01:09 PM
No, that's not the case ( tough, you can fix it by adding ServerName myserver to /etc/apache2/apache2.conf ).

Try this :

sudo apt-get install php5 libapache2-mod-php5

s.fox
July 12th, 2009, 01:12 PM
Hi,

PHP code should be contained within these tags like this:


<?php

echo "This works";

?>

If your HTML page contains ANY php it will need to be saved with php extension. If you are getting an error is it possible for you to post the php script for us to look at?

Thanks,

-Silver Fox

chettiyar
July 12th, 2009, 01:47 PM
Dear Silver_fox_
nobody ever told me abt renaming the file as .php. when i renamed and tried to open with firefox it says - you hav chosen to open a php file from ...... directory, what should firefox do with this file - open with/save file. which appln should i select in open-with and from which directory??? thanx in advance.

credobyte
July 12th, 2009, 01:49 PM
Dear Silver_fox_
nobody ever told me abt renaming the file as .php. when i renamed and tried to open with firefox it says - you hav chosen to open a php file from ...... directory, what should firefox do with this file - open with/save file. which appln should i select in open-with and from which directory??? thanx in advance.

You can't open .php file with Firefox directly ! You need to upload it to your server ( apache2 ). If you do not have one, follow this guide : https://help.ubuntu.com/community/ApacheMySQLPHP

Copernicus1234
July 12th, 2009, 01:57 PM
Dear Silver_fox_
nobody ever told me abt renaming the file as .php. when i renamed and tried to open with firefox it says - you hav chosen to open a php file from ...... directory, what should firefox do with this file - open with/save file. which appln should i select in open-with and from which directory??? thanx in advance.

Php is code that runs on a webserver and the results of the code execution gets delived to your web browser. Thats why you cant run it directly in the browser. Its a server side language. :)

if you want a client side language that runs in the web browser, try JavaScript. :)

Wim Sturkenboom
July 12th, 2009, 02:57 PM
If your HTML page contains ANY php it will need to be saved with php extension. If you are getting an error is it possible for you to post the php script for us to look at?
Must be an Ubuntu specific requirement. It might be advisable but it is not required.

As reference a quote from http://osdir.com/ml/php.general/2002-05/msg01167.html:


Your apache on linux must be configured to parse .html files through php
while your apache on your noteb.. must not, in your apache's httpd.conf
look for the foll. line:
AddType application/x-httpd-php4 .php
AddType application/x-httpd-php4 .phtml
so if you want to parse html files thru php add:
AddType application/x-httpd-php4 .html


Note: you must just search for those addtypes because the may be in another file when using Ubuntu.

Celauran
July 12th, 2009, 03:06 PM
Must be an Ubuntu specific requirement. It might be advisable but it is not required.

As reference a quote from http://osdir.com/ml/php.general/2002-05/msg01167.html:


Note: you must just search for those addtypes because the may be in another file when using Ubuntu.

With PHP and Apache installed, they'll be in /etc/apache2/mods-enabled/php5.conf

chettiyar
July 12th, 2009, 03:06 PM
dear credobyte,
seems ur suggestion solved the problem. thanq very much