We help IT Professionals succeed at work.

PHP Failure Inside An MS Office Generated Webpage

114 Views
Last Modified: 2015-07-31
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 poppersinversion.org 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 http://www.poppersinversion.org/pos/2015/pos-2015-q3.php .  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?

Thanks,
NCM
Comment
Watch Question

Dave BaldwinFixer of Problems
CERTIFIED EXPERT
Most Valuable Expert 2014

Commented:
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.
Most Valuable Expert 2011
Author of the Year 2014
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

Commented:
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>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>PHP Working Demo</title>
    </head>
    <body>
        <h3>Text Before PHP code</h3>
        <?php
              $report = "<p>This sentence is inside php brackets.</p>";
              echo $report;
        ?>
      <h3>Text After PHP code</h3>
    </body>
</html>

I put it in the same folder as before:
http://www.poppersinversion.org/pos/2015/demo.php .

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,
NCM
CERTIFIED EXPERT
Expert of the Year 2008
Top Expert 2008
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

Commented:
Thanks, hielo - That did it!

NCM

Author

Commented:
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 (validator.w3.org) which I will no doubt make good use of in the future.
Dave BaldwinFixer of Problems
CERTIFIED EXPERT
Most Valuable Expert 2014

Commented:
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.
Most Valuable Expert 2011
Author of the Year 2014

Commented:
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.
https://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_11880-Unicode-PHP-and-Character-Collisions.html

Author

Commented:
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.
Dave BaldwinFixer of Problems
CERTIFIED EXPERT
Most Valuable Expert 2014

Commented:
No, that probably won't work because it doesn't automatically remove the BOM.  If your editor will do that, then it will work.
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.