Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Oct 2004
    Location
    Sydney
    Posts
    62
    Thanks
    0
    Thanked 0 Times in 0 Posts

    using PHP in xhtml

    Hi, I'm converting a website from html with .php extensions on the files to an xhtml 1.0 transitional site.

    In the old site there is some php in the html but it doesn’t seem to be working in the new site.
    I tried using .php as the file extensions on the new files, but I get an “XML cant read file” error in the browser.

    What do I do?

    PHP Code:
    <?
    $tipno
    =rand(1,19);
    include 
    "../fintip/tip$tipno.txt"
    ?>

  • #2
    Regular Coder
    Join Date
    Feb 2005
    Location
    West Midlands, UK
    Posts
    623
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Use full PHP tags "<?php ... ?>" instead of short tags "<? ... ?>" and see if that helps (it's good practice anyway since it will make your code much more portable - not every server will have short tags enabled).

  • #3
    New Coder
    Join Date
    Oct 2004
    Location
    Sydney
    Posts
    62
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up fantastic

    thanks. i have no idea about php... always a simple solution.

  • #4
    New Coder
    Join Date
    Oct 2004
    Location
    Sydney
    Posts
    62
    Thanks
    0
    Thanked 0 Times in 0 Posts

    still not working

    Okay ive given putting <?php... instead of <?... but it still does not work. i've checked the file extensions and all that stuff, but i dont have much of an idea about php.. can anyone point me in the right direction here?

    http://www.finser.com.au/nuFINSER/content/fintips.html

    As you can see from the code, ive tried a few variations - but nothing.

  • #5
    Senior Coder
    Join Date
    Jun 2002
    Location
    frankfurt, german banana republic
    Posts
    1,848
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Your server does not send .html files to the PHP interpreter. That's why you still see the PHP code embedded in the XHTML output. What you need to do is to configure your server to also treat files with the extension .html as PHP files. Seeing that you use Apache, the following line in your http.conf might help:

    Code:
    AddType application/x-httpd-php .php .phtml .html
    As a first step, I would make a tiny PHP test page and check that it gets treated correctly by the server. Then I'd switch the extension on your XHTML page. If still some errors appear, they must come from somewhere else.
    De gustibus non est disputandum.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •