math Posted December 27, 2008 Share Posted December 27, 2008 Hi, i'm validating a script o wrote for 95%. One problem is this: (the W3c Validation gives this error, the "?" mark is in red in the code..) Whats wrong of the bold marked area? (60 times.... ???) The validation output link >> http://validator.w3.org/check?uri=http%3A%2F%2Fmarktplaats.b-rainstorm.com%2Findex.php&charset=(detect+automatically)&doctype=Inline&group=0 # Error Line 57, Column 19: an attribute value must be a literal unless it contains only name characters. <a href=rubriek.php?rubriek=2>Audio </a><a href=rubriek.php?rubriek=3>Autos</a>< ✉ You have used a character that is not considered a "name character" in an attribute value. Which characters are considered "name characters" varies between the different document types, but a good rule of thumb is that unless the value contains only lower or upper case letters in the range a-z you must put quotation marks around the value. In fact, unless you have extreme file size requirements it is a very very good idea to always put quote marks around your attribute values. It is never wrong to do so, and very often it is absolutely necessary. The code thats creating the links: <? $mysql_b = "SELECT * FROM links_b ORDER BY pos, naam ASC"; $sql_b = mysql_query($mysql_b); while ($links_b = mysql_fetch_array($sql_b)) { $naam = stripslashes($links_b[naam]); echo "<a href=rubriek.php?rubriek=$links_b[id]>$naam</a>"; } ?> Hope someone can help me You can also contact me trough msn: ontwerpexpert@hotmail.com. I'm also looking for a good student/hobby php writer for some cooperation. Paymen 10.- p/hour. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/138596-solved-validation-question/ Share on other sites More sharing options...
ILMV Posted December 27, 2008 Share Posted December 27, 2008 Easy it should be... <a href="http://...">Blah</a> You need " quotes around the URL... ILMV Quote Link to comment https://forums.phpfreaks.com/topic/138596-solved-validation-question/#findComment-724671 Share on other sites More sharing options...
chronister Posted December 28, 2008 Share Posted December 28, 2008 Here is a good "rule of thumb" to follow. Coding with a particular "style" will help limit errors. This is personal preference, but has helped me to track down errors quickly and even reduce errors in the first place. <?php // you should get in the habit of not using short open tags. Always use <?php not <? $mysql_b = "SELECT * FROM links_b ORDER BY pos, naam ASC"; // use quotation marks around queries $sql_b = mysql_query($mysql_b); while ($links_b = mysql_fetch_array($sql_b)) { $naam = stripslashes($links_b[naam]; // need semi-colon here, indent code to make it easier to read ) // no semi-colon here echo '<a href="rubriek.php?rubriek='.$links_b[id].'">'.$naam.'</a>'; // use apostrophes around html strings and concatenate the variables in them // you had an extra } down here ?> Quote Link to comment https://forums.phpfreaks.com/topic/138596-solved-validation-question/#findComment-724698 Share on other sites More sharing options...
Philip Posted December 28, 2008 Share Posted December 28, 2008 chronister, I'm not sure what you're trying to accomplish. I find it ironic that you had more errors when you put in your own style <?php $mysql_b = "SELECT * FROM links_b ORDER BY pos, naam ASC"; $sql_b = mysql_query($mysql_b); while ($links_b = mysql_fetch_array($sql_b)) { $naam = stripslashes($links_b[naam]; // need semi-colon here, indent code to make it easier to read -- you're missing a ) ) // no semi-colon here -- what?! echo '<a href="rubriek.php?rubriek='.$links_b[id].'">'.$naam.'</a>'; // use apostrophes around html strings and concatenate the variables in them -- but this is outside the loop // you had an extra } down here -- yeah, it was needed ?> This is all that was needed: <?php $mysql_b = "SELECT * FROM `links_b` ORDER BY `pos`, `naam` ASC"; $sql_b = mysql_query($mysql_b); while ($links_b = mysql_fetch_array($sql_b)) { $naam = stripslashes($links_b['naam']); echo '<a href="rubriek.php?rubriek='.$links_b['id'].'">'.$naam.'</a>'; } ?> Simple fix. Quote Link to comment https://forums.phpfreaks.com/topic/138596-solved-validation-question/#findComment-724724 Share on other sites More sharing options...
math Posted December 28, 2008 Author Share Posted December 28, 2008 It's solved! Thank you very much KingPhilip, chronister, Ilmv for the learning and the fixed code. :D Quote Link to comment https://forums.phpfreaks.com/topic/138596-solved-validation-question/#findComment-724789 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.