php not working in html page?

Discussion in 'PHP' started by st3vo, Jun 10, 2010.

  1. #1
    Hi

    I was just wondering if this code is wrong, as I can not see the date.

    <html>
    <head></head>
    <body class="page_bg">
    Hello, today is <?php echo date('l, F jS, Y'); ?>.
    </body>
    </html>

    Is anything here wrong?

    Thankyou in advance


    steve
     
    st3vo, Jun 10, 2010 IP
  2. stephan2307

    stephan2307 Well-Known Member

    Messages:
    1,277
    Likes Received:
    33
    Best Answers:
    7
    Trophy Points:
    150
    #2
    if the file is a .html file then this does not work. However you can add a handler so that apache treats .html the same way as .php.

    There are different ways to do that but the safest is to contact your host and ask them.
     
    stephan2307, Jun 10, 2010 IP
  3. st3vo

    st3vo Active Member

    Messages:
    463
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    58
    #3
    Hi Stephan

    Thank you for helping out.

    I am going through a php tutorial and it says that I need to put php into a html page using the php tags.
    Only I cant seem to work out how to do it. I can view the php file on its own and the html file on there own on my pc on localhost. I'll have to keep watching the php chapter till I can figure out what he has done differently.

    All the best

    Steve
     
    st3vo, Jun 10, 2010 IP
  4. Scripts man

    Scripts man Guest

    Messages:
    51
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    html in php
    not php in html
    i mean you can not add the php in .html pages
     
    Scripts man, Jun 10, 2010 IP
  5. Scripts man

    Scripts man Guest

    Messages:
    51
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    html in php
    not php in html
    i mean you can not add the php in .html pages
     
    Scripts man, Jun 10, 2010 IP
  6. stephan2307

    stephan2307 Well-Known Member

    Messages:
    1,277
    Likes Received:
    33
    Best Answers:
    7
    Trophy Points:
    150
    #6
    ok i see what you mean. You have to change the ending to .php then it will work.
     
    stephan2307, Jun 10, 2010 IP
  7. st3vo

    st3vo Active Member

    Messages:
    463
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    58
    #7
    Thank you guys

    all sorted

    Steve
     
    st3vo, Jun 10, 2010 IP
  8. idpremium

    idpremium Guest

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    just ended with dot php
     
    idpremium, Jun 10, 2010 IP
  9. roopajyothi

    roopajyothi Active Member

    Messages:
    1,302
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    80
    #9
    Everything is perefect just rename the file to blabla.php and check
    I hope you named as .html or .htm before so rename that first :)
     
    roopajyothi, Jun 10, 2010 IP
  10. johny321

    johny321 Member

    Messages:
    293
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    26
    #10
    just save file with file_name.php then it works.
     
    johny321, Jun 10, 2010 IP
  11. lukeg32

    lukeg32 Peon

    Messages:
    645
    Likes Received:
    19
    Best Answers:
    1
    Trophy Points:
    0
    #11
    I dont think your reading the thread properly.....

    Should tell you its all sorted! :p
     
    lukeg32, Jun 10, 2010 IP
  12. roopajyothi

    roopajyothi Active Member

    Messages:
    1,302
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    80
    #12
    Oops he tries to say that its fixed
     
    roopajyothi, Jun 11, 2010 IP