...

View Full Version : validating my php page! help please.



LJackson
04-19-2009, 08:54 PM
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=www.kernow-connect.com%2Fentertainment.php&charset=(detect+automatically)&doctype=Inline&group=0

any assistance please
many thanks

oesxyl
04-19-2009, 10:27 PM
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=www.kernow-connect.com%2Fentertainment.php&charset=(detect+automatically)&doctype=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

venegal
04-19-2009, 11:41 PM
Looking at your source, you did in fact not replace alle the '&' with '$amp;'.

abduraooft
04-20-2009, 09:01 AM
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.

LJackson
04-20-2009, 09:32 AM
Hi All


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.


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

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

<?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

abduraooft
04-20-2009, 10:17 AM
Escape all of them like

echo"

<div class=\"inditemheader\">
<a href=\"{$item->itemlink}\" target=\"_blank">
{$item->title}
</a>
</div>
............."

Or you may use the heredoc (http://php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc)

LJackson
04-20-2009, 10:39 AM
hi mate i have tried the above

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

djm0219
04-20-2009, 11:04 AM
In your $item->itemlink values you need to be replacing the & with &amp; from the looks of it.


$item->itemlink = str_replace('&','&amp;',$item->itemlink);

LJackson
04-20-2009, 11:23 AM
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

djm0219
04-20-2009, 11:51 AM
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.

LJackson
04-20-2009, 11:57 AM
there all definatly &amp; as i had to go throught the hastle of changing them all for my xml file to work :D

but its working now thats the main thing :)

thank you.
Luke



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum