Jump to content

Recommended Posts

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  :D;)

 

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.

 

Link to comment
https://forums.phpfreaks.com/topic/138596-solved-validation-question/
Share on other sites

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

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 :P

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.