...

View Full Version : page wont validate - one or more bytes that validator cannot interpret as utf-8



LJackson
11-12-2009, 01:41 PM
for some reason my site wont allow the validator to run because it says

"Sorry, I am unable to validate this document because on line 609 it contained one or more bytes that I cannot interpret as utf-8 (in other words, the bytes found are not valid values in the specified Character Encoding). Please check both the content of the file and the character encoding indication.

The error was: utf8 "\x92" does not map to Unicode "

i have tried to view the page source and look up line 609 but it doesnt exist?

so i chacked my php file and there was nothing on line 609 which looked incorrect.

this is the section of my php page that is apparently causing the problem

$images = "<div class='smalldiv'><img src='$image' height='200px;' alt='$shortTitle' title='$shortTitle' /></div>";
$iteminfo = "<div class='Desktophot_info_container'>".
"<div class='hot_title'>$shortTitle</div>".
"<div class='hot_description'>$review".
"<div class='buttonsDesktop'>".
"<div class='hot_button1'>".
"<a href='price_results.php?title=$shortTitle&amp;category='".$_SESSION['subpage']."'&amp;info= $artist'><img src='images/compare.gif' alt='compare' title='compare'/></a>".
"</div></div></div></div>";

anyone have any ideas?

i can post the full code if needed?

thanks
Luke

_Aerospace_Eng_
11-12-2009, 01:53 PM
Its not there that is the issue. I loaded your HTML source code in Dreamweaver. Line 609 is the part that has the individual product image.
individual_productImage

<span class="individual_product">
<span class="individual_productImage">
<img src="" height="110px" alt="Night At The Museum: Battle Of The Smithsonian

" title="Night At The Museum: Battle Of The Smithsonian

" />
</span>

<span class="individual_productTitle">
Night At The Museum: Battle Of The Smithsonian

</span>

</span>
</a>
Its complaining about the whitespace you used there. Removing that and revalidating allows it to be validated however there are still errors but they are easy to see what they are.

Kor
11-12-2009, 02:06 PM
I guess it is a problem of how you used the quotes (you have some extra quotes) and added the php variables.


"<a href='price_results.php?title=$shortTitle&amp;category='".$_SESSION['subpage']."'&amp;info= $artist'>"

echoes:


<a href='price_results.php?title=Bruno&amp;category='dvd'&amp;info= '>

I guess you wanted to be:


"<a href='price_results.php?title=$shortTitle&amp;category=".$_SESSION['subpage']."&amp;info=".$artist."'>"

LJackson
11-12-2009, 02:27 PM
hi guys, thanks for the advice,

@ Aerospace the code you printed is set up in my php like so:

<span class="individual_product">
<span class="individual_productImage">
<img src="<?php echo $image ?>" height="110px" alt="<?php echo $shortTitle?>" title="<?php echo $shortTitle?>" />
</span>

<span class="individual_productTitle">
<?php print $shortTitle?>
</span>
</span>

but im not sure where the whhite space is?

@Kor - i tried what you suggested but im still getting the error :(

any other ideas or suggestions?

thanks for your help
Luke

_Aerospace_Eng_
11-12-2009, 02:29 PM
The error Kor pointed out will become visible once you get rid of the whitespace. Its coming from the $shortTitle. Remove the echo for $shortTitle and try to revalidate. You may want to use trim() on the $shortTitle.

LJackson
11-12-2009, 03:01 PM
ok mate i have added trims to all my $shortTitle and i now have the same error for line 449which in my php file is


line 449 -> $review = $row['review'];
line 450 ->$review = trim($review);


any ideas?

i will go throught the code again have prob missed something :)

thanks
Luke

_Aerospace_Eng_
11-12-2009, 03:09 PM
Its not line 449 of your php file because the validator doesn't see that. Its line 449 of your outputted html (view source).

Kor
11-12-2009, 03:14 PM
Anyway, LJackson, first try to see how the HTML code is written by the php (View Source). You will notice the errors easily. Anyway, when generating a HTML document using a server-side language, you should think upside down: first write the HTML code and later write the server-side code line which should generate that HTML code. In other words, try to respect first the HTML (or XHTML - it depends on the used Doctype) rules.

LJackson
11-12-2009, 03:35 PM
hi, ok line 449 of my source code is

<a href="index.php">Home</a> | <a href="contact.php">Contact</a> | <a href="faq.php">FAQ's</a> <br />Copyright Kernow Connect 2008</div>

but i have this as an include on all my pages and they validate ok?

sorry for the trouble :(
Luke

_Aerospace_Eng_
11-12-2009, 03:37 PM
No thats not line 449. I'm not sure how you determined that. I loaded your source code again into dreamweaver and line 449 is this

<a href="price_results.php?title=Transformers: Revenge of the Fallen&amp;category=dvd">
<span class="individual_product">
<span class="individual_productImage">
<img src="" height="110px" alt="Transformers: Revenge of the Fallen" title="Transformers: Revenge of the Fallen" />
</span>

<span class="individual_productTitle">
Transformers: Revenge of the Fallen </span>

</span>

Post the php that generates those details

LJackson
11-12-2009, 03:49 PM
how did you get that as like 449??? lol i opened url and view source and then went to edit goto line and line 449 was the above???

anyways...
this is the code block for that output

<?php
$itemdata = "SELECT *
FROM category_data2
WHERE cat_id = '".$_SESSION['subpage']."'
AND subcat_id = 'New Releases'
ORDER BY id ASC";

$item_query=mysql_query($itemdata)or die(mysql_query);
$num_rows = mysql_num_rows($item_query);

while ($row = mysql_fetch_array($item_query))
{

$shortTitle = htmlspecialchars($row['short_title']);
$shortTitle = preg_replace("/.{0}(with Free).*/", "", $shortTitle) . "\n";
$shortTitle = preg_replace("/.{0}(with Bonus).*/", "", $shortTitle) . "\n";
$shortTitle = trim($shortTitle);
$artist = htmlspecialchars($row['other']);
$image = htmlspecialchars($row['image']);
?>

<a href="price_results.php?title=<?php echo $shortTitle?>&amp;category=<?php echo $_SESSION['subpage']?>">
<span class="individual_product">
<span class="individual_productImage">
<img src="<?php echo $image;?>" height="110px" alt="<?php echo $shortTitle;?>" title="<?php echo $shortTitle?>" />
</span>

<span class="individual_productTitle">
<?php print $shortTitle?>
</span>
</span>
</a>
<?php
} ?>


thanks
Luke

Kor
11-12-2009, 04:05 PM
Once again: you are using incorrectly the quotes in php code and probably add incorrectly some php variables to the strings. For instance, here's an incorrect (X)HTML output:


<a href='price_results.php?title=Formula One Season Review 2009&amp;category=dvd>

You need a final quote. Or you miss something there. As it is now, you have only the opener one

And probably there are more errors like the same.

LJackson
11-12-2009, 04:40 PM
ok found the problem, one of my reviews had a ' in it which was breaking the code :(

anyway i added

mysql_query("SET NAMES 'utf8'");

and its now validating the page even though there are errors which at least i can see now lol,

will crack on with fixing those :)

cheers guys...

may post back if i have any errors i cannot fix :)
Luke

LJackson
11-12-2009, 07:13 PM
got it sorted now :)

thanks guys
Luke



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum