 |
 |
 |
 |
| Servers & Networking Discuss any Fedora server problems and Networking issues such as dhcp, IP numbers, wlan, modems, etc. |

16th September 2004, 09:33 PM
|
|
Registered User
|
|
Join Date: Sep 2004
Posts: 10

|
|
conbining html and php
Hi, I stay here for whole day, need help!!
Env: Fedora 2 full installed. php-4.3.4 with Apache 2.0
Problem: can not run a php page with html code embedded or a html page with php code embedded. Shown up a white page without error msg in Mozilla. But no problem running pure html or pure php (phpinfo page/hello world)
Fedora2 put libphp4.so in http module dir, but it's name is not mod_XXXX and there is no LoadModule item in httpd.conf. I think php is built in Fedora2. So don't care LoadModule ....
exp: ?? it doesn't work
<?php
.......
?>
<HTML>
<HEAD> ....
</HEAD>
<BODY>
<?php print "hello world!" ?>
</BODY>
</HTML>
Help me getting out here.
Last edited by wjudy; 16th September 2004 at 10:06 PM.
|

17th September 2004, 12:02 AM
|
 |
Registered User
|
|
Join Date: Feb 2004
Location: Portugal, Europe
Age: 43
Posts: 519

|
|
|
I'm not sure I understood your problem, but your php pages need to have the ".php" extension. This way, they're handled by the php parser. No need to mess up with any modules at all.
__________________
"I'd crawl over an acre of 'Visual This++' and 'Integrated Development That' to get to gcc, Emacs, and gdb. Thank you."
-- Vance Petree, Virginia Power
|

17th September 2004, 12:35 AM
|
 |
Community Manager
|
|
Join Date: Mar 2004
Location: Vancouver, Canada
Posts: 2,366

|
|
|
I reproduced the scenario above and noted the problem when writing a php embedded in html. It may be a possible bug in the httpd.conf from Apache for Fedora so you submit that problem to the developer. Hower I have no problem running html embedded in php page. I will post a solution if I find one.
__________________
Desktop CPU: AMD Phenom II(tm) X4 Processor 940 AM2+ - Memory: 8GB DDR2-RAM - GPU: Nvidia Geforce GTX 460 v2 - OS: Fedora 18 Spherical Cow x86-64 and Windows 7 Ultimate SP1 64-bit
Laptop Toshiba Satellite C650D - OS: Fedora 19 Schrödinger's Cat (preview release) x86-64 and Microsoft Windows 7 64-bit
Last edited by Finalzone; 17th September 2004 at 12:36 AM.
Reason: Fixed grammatical errors
|

17th September 2004, 12:49 AM
|
 |
Registered User
|
|
Join Date: Aug 2004
Location: Stokes County, North Carolina
Age: 54
Posts: 248

|
|
use <<filename.php>>
I agree with fjleal...
I write quite a bit of php and I always put them in *.php files. Embedding php in html code is fine as long as the filename is *.php. You could actually write all html( with no php code ) in a *.php file and it would work fine as long as php is running on the server. Without the php extension, the php parser doesn't see it.
|

17th September 2004, 01:02 AM
|
|
Guest
|
|
Posts: n/a

|
|
php embeded in html will not get parsed unless you tell apahce to parse it. you need to tell apache to handle the .html extention as it were php. this is not a bug. you can tell apache to do this by editing you .htaccess files in you document root or you can edit your httpd.conf
add this to you .htaccess or httpd.conf file
Code:
Addhandler php-script .php .html .htm
Note: I am assuming you know how to edit these files because you and where to find them. If you don't tell us and we will guide you through it.
Last edited by superbnerd; 17th September 2004 at 01:06 AM.
|

17th September 2004, 01:08 AM
|
 |
Community Manager
|
|
Join Date: Mar 2004
Location: Vancouver, Canada
Posts: 2,366

|
|
|
Thanks, superbnerd. I forgot about that one. :o
__________________
Desktop CPU: AMD Phenom II(tm) X4 Processor 940 AM2+ - Memory: 8GB DDR2-RAM - GPU: Nvidia Geforce GTX 460 v2 - OS: Fedora 18 Spherical Cow x86-64 and Windows 7 Ultimate SP1 64-bit
Laptop Toshiba Satellite C650D - OS: Fedora 19 Schrödinger's Cat (preview release) x86-64 and Microsoft Windows 7 64-bit
|

17th September 2004, 01:37 AM
|
 |
Registered User
|
|
Join Date: Apr 2004
Location: Warsaw, Poland
Age: 32
Posts: 1,085

|
|
|
.html files are meant to serve static pages that is why they got .html extension. to tell the server that this page is static* and to tell the server to not use php interpreter on static page (waste of resources) - if you want to have any .html page parsed via php interpreter you can chage Apache settings - but this will be not so clever to do so (unless you are certainly certain that *every* html page is php page and needs to be interpreted)...
___
* this is not a limitation - but it is kind of de facto standard. usualy we deal with such stuff (serving dynamic (interpreted) and static (f.e. html pages, images) content by setting up two servers on different domains - f.e. static.mydomain.tld serves only images and so on using software that is light (stripped version of Apache, or thttpd or boa) and domain.tld serving full blown (but limited to what it have to do and nothing else) Apache with php and so no, probably behind accelerator/cache...
resources aren't cheap think of them before you have problem with them...
|

17th September 2004, 01:49 AM
|
|
Guest
|
|
Posts: n/a

|
|
or what you could do is make it so every page that ends with .html is static and every page that end with .php or .htm is parsed as php. to do that just add this to you .htaccess
Code:
Addhandler php-script .php .htm
that way all .html pages are left to the default setting.
its best to use .htacces settings instead of changing httpd.conf becasue the changes take affect immediately without restart and your settings only affect a certain directory.
|

20th September 2004, 03:59 AM
|
|
Registered User
|
|
Join Date: Sep 2004
Posts: 10

|
|
|
yes! Thanks! My problem is solved.
|

21st September 2004, 02:57 AM
|
|
Registered User
|
|
Join Date: Sep 2004
Posts: 10

|
|
Link to usr home
Hi: I have a new problem & not sure where caused.
env: FC2's php & httpd with their default httpd.conf & php.ini
docRoot: /var/www/html
For working in the directory : /home/wjudy/a/w/html, I create link to my working dir & from docRoot.And setting option for following link in httpd.conf. It is simple & works well.
1).But it seems something wrong when I insert an img with the src="../img/pic.gif". The mozilla doesn't show the pic. where is the problem comes from? from mozilla? or Server doesnot find the file pic.gif?
2) I never use .htaccess, superbnerd gave a good concept. who give me a good ref for how .
Last edited by wjudy; 21st September 2004 at 04:15 AM.
|

21st September 2004, 04:54 AM
|
 |
Registered User
|
|
Join Date: Aug 2004
Location: Stokes County, North Carolina
Age: 54
Posts: 248

|
|
Quote:
|
1).But it seems something wrong when I insert an img with the src="../img/pic.gif". The mozilla doesn't show the pic. where is the problem comes from? from mozilla? or Server doesnot find the file pic.gif?
|
Show us the php or html code around this so we can help better.
|

22nd September 2004, 04:06 AM
|
|
Registered User
|
|
Join Date: Sep 2004
Posts: 10

|
|
|
i'm new in linux, pls tell me where is the .htaccess file. I can not find this file.
|

22nd September 2004, 04:20 AM
|
|
Guest
|
|
Posts: n/a

|
|
|
there may be a .htaccess file in every directory under you documentroot. you don't have to have one, and if it doesn't exist just create it. they ususally only affect the directory they're in.
|

22nd September 2004, 05:38 AM
|
|
Registered User
|
|
Join Date: Sep 2004
Posts: 10

|
|
|
My test.php file is so simple:
two plus two is <?php echo(2+2); ?>
And I've applied all the thing you talk but the php still doesn't work.
Help
Ps. I did followings:
rpm -qa php
up2date php
yum install httpd php
insert a "LoadModule php4_module modules/libphp4.so" line into "/etc/httpd/conf/httpd.conf"
and create ".htaccess" file which contains the line "Addhandler php-script .php .htm" in "/var/www/html" directory
|

22nd September 2004, 05:51 AM
|
|
Guest
|
|
Posts: n/a

|
|
and what happens when you view the page in your browser? did you start apahce?
Code:
/usr/sbin/apachectl start
do you get any error message? does apache andjust html work?
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
Similar Threads
|
| Thread |
Thread Starter |
Forum |
Replies |
Last Post |
|
HTML / PHP Help.
|
savorxit |
Programming & Packaging |
1 |
20th June 2008 07:07 PM |
|
HTML to PDF
|
Mystinar |
Using Fedora |
5 |
30th October 2007 04:16 PM |
|
Html
|
nderitu |
Using Fedora |
7 |
9th July 2007 04:10 PM |
|
PDF and PS to HTML
|
dotancohen |
Using Fedora |
6 |
15th March 2006 07:32 AM |
|
FC3 FTP to /var/www/html/
|
storkmarg |
EOL (End Of Life) Versions |
1 |
6th December 2005 07:33 PM |
Current GMT-time: 01:28 (Monday, 20-05-2013)
|
|
 |
 |
 |
 |
|
|