Welcome to WebmasterWorld Guest from 54.221.87.97

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Another Can't Parse PHP In html

Sorry for the newbie question

     

Neo541

3:09 pm on Aug 15, 2007 (gmt 0)

10+ Year Member



On my old server, I had it all figured out, but with a new server, my old commands don't work. Basically, as I said, newbie question, but I want to be able to use .html extensions with php parsed on those pages. If it helps, here is my hosts phpinfo file:

Build Date May 15 2007 12:13:56
Configure Command './configure' '--prefix=/usr/local/' '--with-apxs=/etc/httpd/bin/apxs' '--disable-cgi' '--enable-versioning' '--enable-pic' '--disable-posix-threads' '--enable-memory-limit' '--with-pear=/usr/local/lib/php' '--with-openssl=/usr/local/ssl' '--disable-debug' '--enable-magic-quotes' '--disable-rpath' '--with-bz2=/usr' '--with-zlib' '--enable-bcmath' '--enable-calendar' '--enable-ftp' '--enable-exif' '--with-curl=/usr' '--enable-dba' '--with-gdbm=/usr' '--with-flatfile' '--with-inifile' '--enable-dbase' '--with-gd' '--enable-gd-native-ttf' '--with-jpeg-dir=/usr' '--with-png-dir=/usr/local' '--with-freetype-dir=/usr' '--with-gettext=/usr' '--with-gmp' '--with-imap=/usr/local' '--with-imap-ssl=/usr/local/ssl' '--enable-mbstring' '--enable-mbstr-enc-trans' '--enable-mbregex' '--with-mcrypt=/usr' '--with-mhash=/usr' '--with-unixODBC=/usr/local/unixODBC' '--with-mysql=/usr/local/mysql' '--enable-sockets' '--with-regex=system' '--enable-wddx' '--with-expat-dir=/usr' '--enable-xslt' '--with-xslt-sablot=/usr' '--enable-inline-optimization' '--with-pspell=/usr/local' '--with-dom=/usr' '--with-zlib-dir=/usr'
Server API Apache
Virtual Directory Support disabled
Configuration File (php.ini) Path /usr/local/Zend/etc/php.ini
PHP API 20020918
PHP Extension 20020429
Zend Extension 20050606
Debug Build no
Zend Memory Manager enabled
Thread Safety disabled
Registered PHP Streams php, http, ftp, https, ftps, compress.bzip2, compress.zlibp

Thanks for any help!

eelixduppy

4:06 pm on Aug 15, 2007 (gmt 0)

WebmasterWorld Senior Member eelixduppy is a WebmasterWorld Top Contributor of All Time 5+ Year Member



You have to change your server configuration. Go into your httpd.conf or .htaccess and change this line (or something close to it):

addtype application/x-httpd-php .php

to parse .html files like this:


addtype application/x-httpd-php .php .html

Once you do that restart your server and you should be good. :)

Neo541

4:21 pm on Aug 15, 2007 (gmt 0)

10+ Year Member



Makes sense, except I don't have control over the server. How do I get them to restart?

PHP_Chimp

4:26 pm on Aug 15, 2007 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member



If you are using .htaccess then they dont need to restart, as this file is read by the server at each request.
If you dont have access to the server config files then put the line of code above in an htaccess file.

eelixduppy

4:26 pm on Aug 15, 2007 (gmt 0)

WebmasterWorld Senior Member eelixduppy is a WebmasterWorld Top Contributor of All Time 5+ Year Member



You could contact them, however, try it within your .htaccess file first; that is, if your hosting company allows .htaccess. If they don't, you are going to have to contact them and get them to change it for you.

Neo541

4:34 pm on Aug 15, 2007 (gmt 0)

10+ Year Member



Tried it, and it still shows from an earlier test, won't refresh...Need to delete cookies and temp files?

Neo541

4:38 pm on Aug 15, 2007 (gmt 0)

10+ Year Member



Made a new page, this is the error:

test.php A green apple
Warning: main(vars.php) [function.main]: failed to open stream: No such file or directory in /home/mysite/testingphp1.html on line 23

Warning: main(vars.php) [function.main]: failed to open stream: No such file or directory in /home/mysite/testingphp1.html on line 23

Warning: main() [function.include]: Failed opening 'vars.php' for inclusion (include_path='./:/usr/local/lib/php') in /home/mysite/testingphp1.html on line 23
A green apple

Does the line need to be at the very top of the file, it's down a couple lines.

PHP_Chimp

4:40 pm on Aug 15, 2007 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member



If you are using htaccess then this file is requsted internally by the server for each request made. There is no cache on the server.

Your browser is a different matter, so try removing all cookies, sessions, history anything else that you can easily get rid of then try again. As once the htaccess is uploaded it will either break the server and give you a nice 500 error or you it will work.

This is from one of my htaccess files, so defiantly works.
AddType application/x-httpd-php .html

If you want to test if the htaccess is working then put a line of junk in and if that doesnt break the server then it is not working :)
(Just dont start the line of junk with #)

eelixduppy

4:41 pm on Aug 15, 2007 (gmt 0)

WebmasterWorld Senior Member eelixduppy is a WebmasterWorld Top Contributor of All Time 5+ Year Member



>> Made a new page, this is the error:

From this information is seems that php is properly being parsed for that file now, its just that you have errors in your code. Check your code and try again or try something simple:


phpinfo();

[edited by: eelixduppy at 4:42 pm (utc) on Aug. 15, 2007]

PHP_Chimp

4:42 pm on Aug 15, 2007 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member



I type to slowly...

You are getting PHP warnings so PHP is working for .html.
The problem is not with PHP its within the code.

PHP_Chimp

4:42 pm on Aug 15, 2007 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member



Beaten again :(

Neo541

4:58 pm on Aug 15, 2007 (gmt 0)

10+ Year Member



phpinfo();

returned

phpinfo();

That what it's supposed to do?

And the .htaccess works, i've got it redirecting a couple pages.

eelixduppy

5:04 pm on Aug 15, 2007 (gmt 0)

WebmasterWorld Senior Member eelixduppy is a WebmasterWorld Top Contributor of All Time 5+ Year Member




phpinfo();

returned

phpinfo();

That what it's supposed to do?

Well, did you surround it with the php tags <?php and?>

And it just gives you information about php. ;)

Neo541

5:08 pm on Aug 15, 2007 (gmt 0)

10+ Year Member



I'm an idiot. No, I didn't, but once I did, it works. I think i've been staring at this too long with not enough to drink ;)

Works now, so i'll just go back to my code and fix it.

Thanks for the help all!