SitePoint Sponsor

User Tag List

Results 1 to 7 of 7

Thread: html + php

  1. #1
    SitePoint Addict sorin21us's Avatar
    Join Date
    Mar 2009
    Posts
    278
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    html + php

    I have a website that has html and php code. I tried to valid it but I have errors about every < where the php starts. I use DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" and someone told me that strict is not good.
    Can someone please tell me why I have those errors after validation?

  2. #2
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,496
    Mentioned
    163 Post(s)
    Tagged
    4 Thread(s)
    You must not validate the PHP script, but the HTML page that is a result after the PHP has been executed.

    If you validated the HTML page, then the validation errors have nothing to do with the PHP begin and end tags. The real reason for those errors might be anything. To give you an answer, you should provide the errors and the html code, or a link to the page that is giving you problems.

  3. #3
    SitePoint Addict sorin21us's Avatar
    Join Date
    Mar 2009
    Posts
    278
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by guido2004 View Post
    You must not validate the PHP script, but the HTML page that is a result after the PHP has been executed.

    If you validated the HTML page, then the validation errors have nothing to do with the PHP begin and end tags. The real reason for those errors might be anything. To give you an answer, you should provide the errors and the html code, or a link to the page that is giving you problems.
    I saved the page like html, to be validated and the errors are:

    Line 98, Column 73: character "<" is the first character of a delimiter but occurred as data.
    …submit="return checkForm();" action="<?php echo $_SERVER['PHP_SELF']; ?>" met


    document type does not allow element "label" here; missing one of "p", "h1", "h2", "h3", "h4", "h5", "h6", "div", "pre", "address", "fieldset", "ins", "del" start-tag.
    <label class="personal_data_label">Your Name</label>



    Line 128, Column 32: end tag for "body" omitted, but OMITTAG NO was specified.
    <?php include("footer.html"); ?>

  4. #4
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,496
    Mentioned
    163 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by sorin21us View Post
    I saved the page like html, to be validated and the errors are:
    That's not the way to do it. This way, you are validating a page that contains PHP script, and it will never validate.
    You must validate the result of the script after the PHP has been executed. The page as it arrives at your browser. Just validate the pagename.php, don't save it as pagename.html.

  5. #5
    SitePoint Addict sorin21us's Avatar
    Join Date
    Mar 2009
    Posts
    278
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by guido2004 View Post
    That's not the way to do it. This way, you are validating a page that contains PHP script, and it will never validate.
    You must validate the result of the script after the PHP has been executed. The page as it arrives at your browser. Just validate the pagename.php, don't save it as pagename.html.
    I tried to validate index.php and I got this

    Sorry, I am unable to validate this document because its content type is application/octet-stream, which is not currently supported by this service.

    The Content-Type header is sent by your web server (or web browser if you use the file upload interface) and depends on its configuration. Commonly, web servers will have a mapping of filename extensions (such as ".html") to MIME Content-Type values (such as text/html).

  6. #6
    SitePoint Guru james_littler's Avatar
    Join Date
    May 2007
    Location
    Portsmouth, UK
    Posts
    775
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    To rephrase what has been said:

    If you put your .php on a testing server and then browse to it using your internet browser of choice, right click and click view source, save this as an html file and then validate that.

    OR

    Upload the .php to a live server and direct the validator to the URL

    Hope that is a bit easier to understand

  7. #7
    SitePoint Addict sorin21us's Avatar
    Join Date
    Mar 2009
    Posts
    278
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by james_littler View Post
    To rephrase what has been said:

    If you put your .php on a testing server and then browse to it using your internet browser of choice, right click and click view source, save this as an html file and then validate that.

    OR

    Upload the .php to a live server and direct the validator to the URL

    Hope that is a bit easier to understand

    Thank you James. Worked


Bookmarks

Posting Permissions

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