Avatar of Richard Korts
Richard Korts
Flag for United States of America

asked on 

Crazy php code handling

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

Avatar of undefined
Last Comment
Chris Stanyon

8/22/2022 - Mon