Current time: 11-27-2024, 09:31 AM Hello There, Guest! (LoginRegister)


Post Reply 
html extension with php
Author Message
coper Offline
Junior Member
*

Posts: 91
Joined: Nov 2008
Reputation: 0
Post: #1
html extension with php
Hello
I'm trying to run html extension files with php code inside it. I can do it adding this lines to the htaccess file
Code:
AddType application/x-httpd-php .php .htm .html
AddHandler x-httpd-php .php .htm .html
But with this the output of a mysql query is empty or there is nothing printing in the page. Using the same file with the mysql query but changing the extension of the file to php I can see the output line of the query without problem, so the query is ok.
Now I want to try to add this lines to the apache config
Code:
<IfModule mod_mime.c>
AddType application/x-httpd-php .php
AddType application/x-httpd-php .phtml
AddType application/x-httpd-php .php3
AddType application/x-httpd-php .php4
AddType application/x-httpd-php .html
AddType application/x-httpd-php-source .phps
</IfModule>
But I don't know in which config file I need to add it. Can you tell me that?
And if you had the same problem with the html extension and php code please tell me too.

Thanks for your help.

Greetings.

c.
03-04-2009 02:50 AM
Find all posts by this user Quote this message in a reply
coper Offline
Junior Member
*

Posts: 91
Joined: Nov 2008
Reputation: 0
Post: #2
RE: html extension with php
I found the file to add that lines but still don't work.
Anyone knows how can I do to use php code inside a html file?
I can do it adding this to a htaccess file
Code:
<FilesMatch "\.(htm|html|php)$">
SetHandler application/x-httpd-php
</FilesMatch>
php works but I get Fatal error: Call to undefined function: mysql_connect()
And if the file has php extension I don't get that error.
03-04-2009 03:58 AM
Find all posts by this user Quote this message in a reply
la1o Offline
Junior Member
*

Posts: 11
Joined: Nov 2008
Reputation: 0
Post: #3
RE: html extension with php
you dont need do that, only need to use mod_rewrite
for example

RewriteRule (.*)\.html$ $1.php [L]

maybe that works better
03-04-2009 12:22 PM
Find all posts by this user Quote this message in a reply
coper Offline
Junior Member
*

Posts: 91
Joined: Nov 2008
Reputation: 0
Post: #4
RE: html extension with php
Thanks for the answer
I will try to do what you said. Please can you tell me where I need to put that?
03-04-2009 10:06 PM
Find all posts by this user Quote this message in a reply
la1o Offline
Junior Member
*

Posts: 11
Joined: Nov 2008
Reputation: 0
Post: #5
RE: html extension with php
in your .htaccess or apache conf
03-05-2009 02:13 AM
Find all posts by this user Quote this message in a reply
coper Offline
Junior Member
*

Posts: 91
Joined: Nov 2008
Reputation: 0
Post: #6
RE: html extension with php
I did it but I don't know what is wrong. When I put that in the htaccess file I go to the url of the site and the internet browser want to download a file without extension and with the name of the site. I downloaded the file and opened it with a text editor and I saw the html code.

I have no idea why this happens. Another suggestion?

Thank you again.


c.
(This post was last modified: 03-05-2009 03:07 AM by coper.)
03-05-2009 03:05 AM
Find all posts by this user Quote this message in a reply
la1o Offline
Junior Member
*

Posts: 11
Joined: Nov 2008
Reputation: 0
Post: #7
RE: html extension with php
for example

i visit http://dom.cl/test.html

but with this rule RewriteRule (.*)\.html$ $1.php [L]

i really enter to

http://dom.cl/test.php

so test.php must exist and not test.html file
you maybe need to read about mod_rewrite

(sorry for my english)
03-05-2009 04:42 AM
Find all posts by this user Quote this message in a reply
coper Offline
Junior Member
*

Posts: 91
Joined: Nov 2008
Reputation: 0
Post: #8
RE: html extension with php
I need a different thing. There isn't php files in the website, I only have html files. So what I need to do is to run php code inside html files. I need html files to understand php code.


c.
03-07-2009 05:58 PM
Find all posts by this user Quote this message in a reply
kilburn Offline
Development Team
*****
Dev Team

Posts: 2,182
Joined: Feb 2007
Reputation: 34
Post: #9
RE: html extension with php
Try adding the following to /etc/apache2/ispcp/domain.tld.conf
Code:
<IfModule mod_fcgid.c>
  AddHandler fcgid-script .html
</IfModule>
(This post was last modified: 03-10-2009 02:31 AM by kilburn.)
03-10-2009 02:31 AM
Visit this user's website Find all posts by this user Quote this message in a reply
coper Offline
Junior Member
*

Posts: 91
Joined: Nov 2008
Reputation: 0
Post: #10
RE: html extension with php
Didn't work.

I had to use an iframe to insert the php file with the code. That was the only way. Anyway I wish I could write php code in html files. Still looking for a solution.

Thanks a lot for the help.

Regards.

c.
03-13-2009 04:03 PM
Find all posts by this user Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)