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 11 of 11
  1. #1
    Senior Coder
    Join Date
    Jun 2008
    Location
    Cornwall
    Posts
    2,099
    Thanks
    297
    Thanked 12 Times in 12 Posts

    Arrow validating my php page! help please.

    Hi all,

    i have several pages which display data from my own feed i have replaced all the &'s with & but im still getting validation errors relating to the use of &'s

    here is the link
    http://validator.w3.org/check?uri=ww...Inline&group=0

    any assistance please
    many thanks
    Last edited by LJackson; 04-19-2009 at 10:06 PM.

  • #2
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by LJackson View Post
    Hi all,

    i have several pages which display data from my own feed i have replaced all the &'s with & but im still getting validation errors relating to the use of &'s

    here is the link
    http://validator.w3.org/check?uri=ww...Inline&group=0

    any assistance please
    many thanks
    it's valid, I tested with xmllint and I don't get any warning or error.

    best regards

  • #3
    Gütkodierer
    Join Date
    Apr 2009
    Posts
    2,127
    Thanks
    1
    Thanked 426 Times in 424 Posts
    Looking at your source, you did in fact not replace alle the '&' with '$amp;'.

  • #4
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,865
    Thanks
    160
    Thanked 2,224 Times in 2,211 Posts
    Quote Originally Posted by venegal View Post
    Looking at your source, you did in fact not replace alle the '&' with '$amp;'.
    You meant & ?

    Hi LJackson, enclose all your attribute values with double quotes rather tan single quotes.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #5
    Senior Coder
    Join Date
    Jun 2008
    Location
    Cornwall
    Posts
    2,099
    Thanks
    297
    Thanked 12 Times in 12 Posts
    Hi All

    Quote Originally Posted by oesxyl View Post
    it's valid, I tested with xmllint and I don't get any warning or error.

    best regards
    Hi mate,
    the xml document is valid but for some reason the html markup is throwing up 21 errors which are all related to the xml file and im not sure why.

    Quote Originally Posted by venegal;
    Looking at your source, you did in fact not replace alle the '&' with '$amp;'.
    hi mate, all the &'s have been replaced because i had to replace them all for the xml file to work which is why im stumped as to why im getting these errors.

    @abduraooft: hi mate, if i enclose my attributes in double quotes on my php page i just get the name of the variable and if i enclose the urls in double quotes in my xml file the links dont work?

    any ideas guys

    here is a snippet from my php page and my xml file

    php
    PHP Code:
            print "<div class='recommends'>";
            
    //echo $stores[$i];
            //echo $feedID[$i];
            //Top items info
               
            
    if ($feedID[$i] == "custom" ){
            
    $xml=simplexml_load_file("http://www.kernow-connect.com/feeds/testprodfeed.xml");
            foreach (
    $xml->store as $item){
            if (
    $item->name == $stores[$i]){
            echo
    "
            
                    <div class='inditemheader'>
                    <a href='{$item->itemlink}' target='_blank'>
                    {$item->title}
                    </a>
                    </div>
                    
                    <div class='inditemimg'>
                    <a href='{$item->itemlink}' target='_blank'>
                    <img src='{$item->topitem}' alt='{$item->title}' title='{$item->title}' 
                    height='100' border='0' /></a>
                    </div>
                                        
                    <div class='inditemprice'>
                    {$item->price}
                    </div>
                        
                    <div class='inditeminfo'>
                    <a href='{$item->itemlink}' target='_blank'>
                    More Info
                    </a>
                    </div>
                        
                    <div class='inditemdesc'>{$item->desc}</div>"
    ;
            }
    }

    xml
    Code:
    <?xml version="1.0" encoding="utf-8"?>
    <!DOCTYPE stores SYSTEM "http://www.kernow-connect.com/xmlschema.dtd">
    <stores>
    <store>
    	<name>Play</name>
    	<title>Slumdog Millionaire</title>
    	<topitem>http://images.play.com/covers/5890462m.jpg</topitem>
    	<desc>A Penniless, eighteen year-old orphan from the slums of Mumbai, he's one question away from winning a staggering 20 million rupees on India's "Who Wants To Be A Millionaire?" But when the show breaks for the night, suddenly, he is arrested on suspicion of cheating.</desc>
    	<itemlink>http://www.awin1.com/cread.php?awinmid=1418&amp;awinaffid=79524&amp;clickref=playtop&amp;p=http%3A%2F%2Fwww.play.com%2FDVD%2FDVD%2F4-%2F5890462%2FSlumdog-Millionaire%2FProduct.html%23</itemlink>
    	<price>£11.99</price>
    </store>
    <store>
    	<name>Game</name>
    	<title>The Godfather 2</title>
    	<topitem>http://img.game.co.uk/ml/3/3/4/0/334030ps.gif</topitem>
    	<desc>After being promoted by Michael Corleone to Don of New York, players expand to new cities, as they build up their families through extorting businesses, monopolizing illegal crime rings and defeating new families in an effort to become the most powerful mob family in America</desc>
    	<itemlink>http://clkuk.tradedoubler.com/click?p(12813)a(1515427)g(80187)url(http://www.game.co.uk/Xbox360/Action/~r334030/The-Godfather-2/)</itemlink>
    	<price>£39.99</price>
    </store>
    </stores>
    
    any help appreciated :)
    cheers

  • #6
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,865
    Thanks
    160
    Thanked 2,224 Times in 2,211 Posts
    Escape all of them like
    PHP Code:
    echo"
            
                    <div class=\"inditemheader\">
                    <a href=\"{$item->itemlink}\" target=\"_blank"
    >
                    {
    $item->title}
                    </
    a>
                    </
    div>
    .............

    Or you may use the heredoc
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #7
    Senior Coder
    Join Date
    Jun 2008
    Location
    Cornwall
    Posts
    2,099
    Thanks
    297
    Thanked 12 Times in 12 Posts
    hi mate i have tried the above
    PHP Code:
            if ($feedID[$i] == "custom" ){
            
    $xml=simplexml_load_file("http://www.kernow-connect.com/feeds/testprodfeed.xml");
            foreach (
    $xml->store as $item){
            if (
    $item->name == $stores[$i]){
            echo
    "
            
                    <div class=\"inditemheader\">
                    <a href=\"{$item->itemlink}\" target=\"_blank\">
                    {$item->title}
                    </a>
                    </div>
                                    
                    <div class=\"inditemimg\">
                    <a href=\"{$item->itemlink}\" target=\"_blank\">
                    <img src=\"{$item->topitem}\" 
                    alt=\"{$item->title}\" 
                    title=\"{$item->title}\" 
                    height=\"100\" border=\"0\" />
                    </a>
                    </div>
                                        
                    <div class=\"inditemprice\">
                    {$item->price}
                    </div>
                        
                    <div class=\"inditeminfo\">
                    <a href=\"{$item->itemlink}\" target=\"_blank\">
                    More Info
                    </a>
                    </div>
                        
                    <div class=\"inditemdesc\">{$item->desc}</div>"
    ;
            }
    }

    but im still getting the same errors ive looked through the page you provided but it all looks way to complex for my simple mind

    any other ideas?

    cheers mate
    Luke

  • #8
    Senior Coder djm0219's Avatar
    Join Date
    Aug 2003
    Location
    Wake Forest, North Carolina
    Posts
    1,312
    Thanks
    4
    Thanked 206 Times in 203 Posts
    In your $item->itemlink values you need to be replacing the & with &amp; from the looks of it.

    PHP Code:
    $item->itemlink str_replace('&','&amp;',$item->itemlink); 
    Dave .... HostMonster for all of your hosting needs

  • Users who have thanked djm0219 for this post:

    LJackson (04-20-2009)

  • #9
    Senior Coder
    Join Date
    Jun 2008
    Location
    Cornwall
    Posts
    2,099
    Thanks
    297
    Thanked 12 Times in 12 Posts
    Hi djm0219,

    thank you very much that has solved the problem

    but my question is why do i need to do this if i have already replaced them in the xml file???

    many thanks
    Luke

  • #10
    Senior Coder djm0219's Avatar
    Join Date
    Aug 2003
    Location
    Wake Forest, North Carolina
    Posts
    1,312
    Thanks
    4
    Thanked 206 Times in 203 Posts
    I suspect that simplexml_load_file is converting them back to simply & but I don't know that for a fact. If I look at your XML file directly it looks like it contains just & but I can't be 100% sure since I'm looking at it with a browser.
    Dave .... HostMonster for all of your hosting needs

  • #11
    Senior Coder
    Join Date
    Jun 2008
    Location
    Cornwall
    Posts
    2,099
    Thanks
    297
    Thanked 12 Times in 12 Posts
    there all definatly &amp; as i had to go throught the hastle of changing them all for my xml file to work

    but its working now thats the main thing

    thank you.
    Luke


  •  

    Posting Permissions

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