Click to See Complete Forum and Search --> : clean code
tefnut
02-13-2007, 06:52 AM
I have been trying to make my website valid HTML, I have managed to alter the php so that the '&' appear as '&' using htmlentities but there still seems to be a prob with the text when it comes out of the database; it makes: �� where there are ' is there some other code cleaning that can sort this? here is my code:
function list_category($cat)
{
$cat_query = mysql_query("select * from subcategory where sc_ref = $cat");
while($cat_data = mysql_fetch_array($cat_query))
{
$sc_nameVar = htmlentities(stripslashes($cat_data[sc_name]));
print "<div class=\"topNavItems\"><a href=\"listing.php?cat={$cat_data[sc_cat]}\">$sc_nameVar</a></div>\n";
}
}
please can anyone help this newby, thanks
chrisranjana
02-13-2007, 07:37 AM
What does this html validation tool (http://validator.w3.org/) say ? error at which line ? and what error ?
tefnut
02-13-2007, 07:42 AM
Sorry it says:
Error Line 243 column 59: non SGML character number 146.
<div class="topNavItems"><a href="listing.php?cat=44">Lloyd��s Brokers</a></div>You have used an illegal character in your text. HTML uses the standard UNICODE Consortium character repertoire, and it leaves undefined (among others) 65 character codes (0 to 31 inclusive and 127 to 159 inclusive) that are sometimes used for typographical quote marks and similar in proprietary character sets. The validator has found one of these undefined characters in your document. The character may appear on your browser as a curly quote, or a trademark symbol, or some other fancy glyph; on a different computer, however, it will likely appear as a completely different character, or nothing at all.
Your best bet is to replace the character with the nearest equivalent ASCII character, or to use an appropriate character entity. For more information on Character Encoding on the web, see Alan Flavell's excellent HTML Character Set Issues reference.
This error can also be triggered by formatting characters embedded in documents by some word processors. If you use a word processor to edit your HTML documents, be sure to use the "Save as ASCII" or similar command to save the document without formatting information.