Link to home
Start Free TrialLog in
Avatar of NonComposMentis
NonComposMentisFlag for United States of America

asked on

PHP Failure Inside An MS Office Generated Webpage

Greetings Experts,

I have a problem with getting php to work inside a document that was auto-generated by MS Office (Outlook to be precise).  I had some code I wanted to put into the newsletter.  The newsletter is created in stages, one of which is normally to save an Outlook message to an html file.  This time, I decided to put some code in the page.  My Linux web host supports php, and I had previously had the code written and tested, but when put in the newsletter page it did not work.  In fact NO php code works inside the Office generated page.   You can see for yourself at .  Look at the page source and search for the variable $report.  You can literally see the php code!  I suspect this has something to do with all the schemas that were loaded, but then which one and is it necessary?  Or is it something else?

Avatar of Dave Baldwin
Dave Baldwin
Flag of United States of America image

Nope.  I downloaded your page and ran it locally and it works fine.  For some reason, the PHP code is not being run in that page on your server.  That's what you have to look for.  See if there is an '.htaccess' file that is blocking it in that directory.
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of NonComposMentis


Thank you for your replies.

Ray - as far as the publishing strategy goes, you are probably right.

Dave, Ray - The problem is not squarely on the shoulders of my server.  As alluded to in my original question, the code I wanted to insert was already tested and working.

Here is a skeletal demo page with the very same php code that was in the newsletter link I gave you:

<!DOCTYPE html>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>PHP Working Demo</title>
        <h3>Text Before PHP code</h3>
              $report = "<p>This sentence is inside php brackets.</p>";
              echo $report;
      <h3>Text After PHP code</h3>

I put it in the same folder as before: .

The demo works perfectly from my server.  So if the newsletter works for you and not me, there must be some interplay between my server and and the newsletter document that causes it to fail on my server.  If it helps, I'm linking the php configuration dump here.

The bottom line in this situation is that my hosting service is just going to say their php service works just fine.

Thank you,
Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks, hielo - That did it!

hielo resolved my issue and thereby earns the most points.  Ray Paseur put in significant effort and while he didn't get me to a resolution this time, he did provide me with a resource ( which I will no doubt make good use of in the future.
That makes sense.  I downloaded your file and opened it in my code editor which probably removed the BOM because I certainly didn't see it.
For more information on the issues you may encounter when you're using the less popular (read "fringe") character encodings, check out this article.  PHP is making a full-on push to move to UTF-8.
Thanks, Ray.

Dave - I thought of that too, after the question was closed.  What if I just take what the browser sees as its "page source" and re-post that as a php file?  But right now I've got a deadline to meet.
No, that probably won't work because it doesn't automatically remove the BOM.  If your editor will do that, then it will work.