2

I have a set of PHP scripts running in HTML files for a project. There is a main window with tabs and each tab calls one of these HTML-inclusive-of-PHP files. For this purpose, I am using iframes. The PHP scripts connect to a MySQL database to retrieve data and display as required by the user. I am using WAMP for this purpose and have set a HTML page as the index file. However, if I give a HTML page as the index file, the tabs do not respond. As in, I can see the tab but it doesn't connect to the database and doesn't retrieve data. If I save the same file without any changes as a PHP index file instead, I cannot see the frames and tabs anymore, but the PHP script works and data is retrieved effortlessly from the database. I tried this with every one of my tabs and every time, the PHP script works while the HTML including the PHP doesn't. What am I doing wrong ? How do I make the HTML page with the PHP work ?

1

2 Answers 2

2

The way to execute PHP on a .html page is to modify your .htaccess file. This file may be hidden, so depending upon your FTP program you may have to modify some settings to see it. Then you just need to add this line for .html:

AddType application/x-httpd-php .html`

Or for .htm

AddType application/x-httpd-php .htm`

If you only plan on including the PHP on one page, it is better to setup this way:

<Files yourpage.html>
AddType application/x-httpd-php .html
</Files>

This code will only make the PHP executable on the yourpage.html file, and not on all of your html pages.

or in httpd.conf if you want it globally

Sign up to request clarification or add additional context in comments.

3 Comments

or in httpd.conf if he wants it globally
I already tried that. It made my localhost to download the php file instead of parsing it for some reason so that didn't exactly work. Any other options ??
I had to remove the "application/" part and also add php5 instead of php. Works now. Thanks for your help !
0

Left click on the Wamp icon in the bottom right tray of your computer >> Apache >> left click on httpd.conf >> scroll 2/3rd's the way down >> add AddType application/x-httpd-php .html to as shown below >> save and close it >> restart Wamp >> Done!


AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
AddType application/x-httpd-php .php
AddType application/x-httpd-php .php3
AddType application/x-httpd-php .html

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.