onArcade Forums

Full Version: game descriptions ambersands
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

In some games at description appear ambersand glyphs like:

Climb the world's tallest monuments and reach seventh heaven!

What have to change to appear correctly?


thank you
Here after copy past appear correctly

At site eg in word world's the "'" appears as
& # 39 ; (with no spaces)
thanks
So you want to change ' to that? htmlspecialchars function should do this, open file.php and change both
PHP Code:
$file_row['description'
to
PHP Code:
htmlspecialchars($file_row['description'], ENT_QUOTES"UTF-8"
and then change
PHP Code:
$related_row['description'
to
PHP Code:
htmlspecialchars($related_row['description'], ENT_QUOTES"UTF-8"
and then in includes/functions.php change
PHP Code:
function shorten_description($description$length) {
    if (
strlen($description) > $length) {
        if (
function_exists('mb_strtolower')) {
            return 
mb_substr($description 0, ($length 3), 'UTF-8') .'...';
        } else {
            return 
substr($description 0, ($length 3)) .'...';
        }
    } else
        return 
$description;

to
PHP Code:
function shorten_description($description$length) {
    
$description htmlspecialchars($descriptionENT_QUOTES"UTF-8");
    if (
strlen($description) > $length) {
        if (
function_exists('mb_strtolower')) {
            return 
mb_substr($description 0, ($length 3), 'UTF-8') .'...';
        } else {
            return 
substr($description 0, ($length 3)) .'...';
        }
    } else
        return 
$description;

I think this should do it.
thanks for fast reply, will try it today and will answer here

manos
Hm, not working
Maybe i did not write correctly the question

I want description at site to appear:
' and not & # 39 ;
! and not & # 33 ;
thanks
manos
Although not an ideal solution (depends how many you have) select edit file and then simply click save, no need to change anything, the correct characters will be applied.
Thanks for response.
Actually the problem is in printing
Although & # 39 is the ampersand for ' , it prints the ambersand code and not '

thanks anyway

manos
Maybe i was not clear enough.
So i uploaded an image to see my problem with script
http://www.imagehack.biz/onarcade.jpg

should be ' and ! and not these codes.

Any help appreciated

manos
Maybe i was not clear enough.
So i uploaded an image to see my problem with script
[Image: onarcade.jpg]

should be ' and ! and not these codes.

Any help appreciated

manos
where do these tags come from? onArcade does not strip HTML tags in descriptions, so they should be displayed right... or have you added nohtml() function to descriptions?
No i did not add anything.
But i saw also at other sites that at same games there are the same problems in description.

thanks
manos
Near to solution
The problem is the "amp;" 4 characters that should not exist.
Without this the ambersand code is printing ok eg # 3 9 ; without spaces is printed as '.
So need only to add at description printing something like replace(description,"amp;","") in asp.
How is this command in php?

thanks
If not available i will write an asp script to replace at mysql all amp; with blanc

manos
Do you have that & in your database? In that case running this query should fix it:
Code:
UPDATE on_files SET description = REPLACE(description, '&', '&');
This works, thanks Hans
Reference URL's