Why does my php code get automatically removed from html?

Discussion in 'HTML & Website Design' started by knownowppc, Nov 11, 2009.

  1. #1
    I have this 1 line of php code in my html page:

    <?php if ($_GET['exitpop']=='no'){ echo "<!--"; } ?>

    but somehow when I upload it to the server, & view the source of the page.. it's not there (automatically removed).

    I also tried to rename my html page to php extension just to see if it'll retain the 1 line code.. but nope, it's still gone.
     
    knownowppc, Nov 11, 2009 IP
  2. Glowing Face Man

    Glowing Face Man Peon

    Messages:
    31
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Is that line showing up when you "View Source" of the page? If so, it's there, it's just not being translated as php by the server...

    if that's the case, try adding this at the top of the .htaccess file in the folder this is in...

    AddHandler application/x-httpd-php5 .html
    Code (markup):
    (Or replace php5 with whatever php version the server has...)
     
    Glowing Face Man, Nov 11, 2009 IP
  3. knownowppc

    knownowppc Peon

    Messages:
    331
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Hmm tried exactly that, but still removes the php line in my html code. The server has php 5.2.5
     
    knownowppc, Nov 11, 2009 IP
  4. Dave B

    Dave B Member

    Messages:
    35
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #4
    What extension does the page have .php or .html?
     
    Dave B, Nov 12, 2009 IP
  5. theapparatus

    theapparatus Peon

    Messages:
    2,925
    Likes Received:
    119
    Best Answers:
    0
    Trophy Points:
    0
    #5
    How are you trying to upload this file? Via ftp? A file manager? Walking us through with details would be helpful.
     
    theapparatus, Nov 12, 2009 IP
  6. vlwebhosting

    vlwebhosting Guest

    Messages:
    25
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    what editor u r using for this? as dreamwaver can do taht automatically
     
    vlwebhosting, Nov 12, 2009 IP
  7. knownowppc

    knownowppc Peon

    Messages:
    331
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    It has .html

    I'm uploading via ftp (when I download the file back again to new destination, I do see the php code)

    I'm using Kompozer, however just using notepad to add the php code so that it doesn't mess it up.
     
    knownowppc, Nov 12, 2009 IP
  8. Mark Henderson

    Mark Henderson Well-Known Member

    Messages:
    402
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    110
    #8
    All PHP source code is hidden from the user, all you will see when you view the source is html.

    Does the code actually work?
     
    Mark Henderson, Nov 13, 2009 IP
  9. Kerosene

    Kerosene Alpha & Omega™ Staff

    Messages:
    11,366
    Likes Received:
    575
    Best Answers:
    4
    Trophy Points:
    385
    #9
    Unless you've fiddled around to allow html extensions to parse php, then you MUST use .php as your file extension.
     
    Kerosene, Nov 13, 2009 IP
  10. knownowppc

    knownowppc Peon

    Messages:
    331
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #10
    Aah i get it. Well I'm still creating a test scenario so will check and update this thread. thanks!!
     
    knownowppc, Nov 14, 2009 IP