troubleshooting Question

Crazy php code handling

Avatar of Richard Korts
Richard KortsFlag for United States of America asked on
PHPWeb BrowsersChrome
7 Comments1 Solution49 ViewsLast Modified:
I have this code as a part of a larger program, I just added this code today:

<?php if ($r == "sent") { ?>
                  <div class="row">
                        <div class="col-xs-1 col-sm-1 col-md-1">&nbsp;</div>
                        <div class="col-xs-10 col-sm-10 col-md-10 text-center" style="padding-top:20px;font-size:20px;"><b>Emails sent as follows:</b><br>
                        <?php for ($i= 0; $i < $ne; $i++) {
                        print $msg[$i] . "<br>";
                        } ?>
                        <br>
                        <input type="submit" value="Dismiss Emails Message" onMousedown="ac='d';" style="color:white; background-color: #5B9BD5; border-radius: 10px; border-style: solid; border-color:#41719C; box-shadow: 4px 4px 2px #C3BDBD;"
                        </div>
                        <div class="col-xs-1 col-sm-1 col-md-1">&nbsp;</div>
                  </div>      
                  <? } ?>

If this code is included as is on the live server, it gives me a 500 error. If I change the leading <?php to just <?, it runs, but produces crazy results. I was beginning to think I lost my mind on how to embed php code in html.

To debug, I used Chrome debugger, it steps through & gives me all kinds of nonsense things, but one key I noted is that in view source the php code (above) is in a green shade of text.

When I run this exact same code on my trusty development server, it works as intended.

Images attached show result of IDENTICAL code on both servers. One called bad is the one that does crazy things.

Any ideas?
bad.PNG
good.PNG
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 7 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 7 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros