sgmurphy19 Posted January 16, 2007 Share Posted January 16, 2007 When I run the following code in a php file it works fine. But if I put it in an html body it bombs out when I call a function within a function, a.k.a. at the "->" part of the code.<?phpinclude ("include/configuration.php");include ("include/class.database.php");include ("include/class.surveyresponse.php");$surveyresponseList = Array();$Database = new DatabaseConnection();$query = "select * from surveyresponse";$Database->Query($query);for ($i=0; $i < $Database->Rows(); $i++){ $surveyresponse = new SurveyResponse(); $surveyresponse->Get($Database->Result($i,"surveyresponseid"));}?>Here is the output page:"Query($query); for ($i=0; $i < $Database->Rows(); $i++) { $surveyresponse = new SurveyResponse(); $surveyresponse->Get($Database->Result($i,"surveyresponseid")); echo $surveyresponse->"...As you can see evrything is fine until it hts the first sub-call.Any ideas?Thanks,Sean Quote Link to comment https://forums.phpfreaks.com/topic/34455-php-in-html-file-error/ Share on other sites More sharing options...
Jessica Posted January 16, 2007 Share Posted January 16, 2007 For php code to run, the file extension must be .php Quote Link to comment https://forums.phpfreaks.com/topic/34455-php-in-html-file-error/#findComment-162242 Share on other sites More sharing options...
AbydosGater Posted January 16, 2007 Share Posted January 16, 2007 When you say in a html file is that like .html or just in a <body> tag?And what errors are you getting?-Andy Quote Link to comment https://forums.phpfreaks.com/topic/34455-php-in-html-file-error/#findComment-162243 Share on other sites More sharing options...
Daniel0 Posted January 16, 2007 Share Posted January 16, 2007 To make Apache parse .html files as PHP, add this to your httpd.conf file: [code]AddType application/x-httpd-php .html[/code] Quote Link to comment https://forums.phpfreaks.com/topic/34455-php-in-html-file-error/#findComment-162246 Share on other sites More sharing options...
sgmurphy19 Posted January 16, 2007 Author Share Posted January 16, 2007 Thanks for the fast responses. When I said html body, I did mean a .html file. I will try adding the extension mentioned in the httpd.conf file and reply back. Quote Link to comment https://forums.phpfreaks.com/topic/34455-php-in-html-file-error/#findComment-162255 Share on other sites More sharing options...
scott212 Posted January 16, 2007 Share Posted January 16, 2007 why don't you just change the file extension to .php? I'm quite surprised you've come this far and are not aware of this. Pretty fundamental Quote Link to comment https://forums.phpfreaks.com/topic/34455-php-in-html-file-error/#findComment-162268 Share on other sites More sharing options...
AbydosGater Posted January 16, 2007 Share Posted January 16, 2007 Lol.. Great point..-Andy Quote Link to comment https://forums.phpfreaks.com/topic/34455-php-in-html-file-error/#findComment-162272 Share on other sites More sharing options...
sgmurphy19 Posted January 16, 2007 Author Share Posted January 16, 2007 Daniel,The addition to the httpd.conf file solved it all! Thanks!Sean Quote Link to comment https://forums.phpfreaks.com/topic/34455-php-in-html-file-error/#findComment-162291 Share on other sites More sharing options...
scott212 Posted January 16, 2007 Share Posted January 16, 2007 It may have fixed it but unless you specifically need that, it's not your best option. You'll have more server overhead now since php will process ALL of the web requests if your site is made up of html and php files. Quote Link to comment https://forums.phpfreaks.com/topic/34455-php-in-html-file-error/#findComment-162415 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.