homepage Welcome to WebmasterWorld Guest from 50.19.169.37
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Another Can't Parse PHP In html
Sorry for the newbie question
Neo541




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

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




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

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




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

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

PHP_Chimp




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

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




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

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




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

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

Neo541




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

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




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

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




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

>> 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




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

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




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

Beaten again :(

Neo541




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

phpinfo();

returned

phpinfo();

That what it's supposed to do?

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

eelixduppy




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


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




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

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!

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved