0

I am designing a website that requires me to show the outputs of a mysql database on a webpage written in html. However my browser doesn't seem to recognize the php scripts within the html file and returns blank values where their should be details. The scripts worked fine in the .php files but have no effect when included in the .html files even after creating a .htaccess file as instructed in previously asked questions. Is there anything else that can be done to solve this issue?

9
  • There are different ways of triggering PHP scripts to run in files with a .HTML extension, depending on the configuration of your server. Commented Jul 13, 2015 at 12:33
  • 3
    Is the file extension if your html page .php? Commented Jul 13, 2015 at 12:33
  • 1
    Browsers don't care about php scripts. You need to configure your server to treat .html files as php. Commented Jul 13, 2015 at 12:35
  • The browser doesn't execute PHP code. If the PHP code is being sent to the browser at all then either your PHP server isn't configured correctly or you're doing something wrong. Commented Jul 13, 2015 at 12:35
  • 2
    Save your file with .php extension Commented Jul 13, 2015 at 12:37

1 Answer 1

1

There are two methods (that I've encountered) of changing the environment on an Apache server via .htaccess to allow PHP scripts to be processed in .html files, depending on the configuation. Whichever of these you've attempted, try the other.

AddHandler application/x-httpd-php5 .php .html .htm

Or

AddHandler cgi-script .html 
SetEnv PHP_EXTENSION .html
Sign up to request clarification or add additional context in comments.

1 Comment

I tried the first mthod and it didnt seem to have any effect, I will give the second one a try. Hopefully it will work. Thanks

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.