Jump to content

Avoid strange character like € ®


eevan79

Recommended Posts

I am not sure is this question is in right section, but I have problem with some strange characters.

Can I somehow remove this character via .php script?

This is screenshots:

001xt.jpg

This is how it looks in Mysql:

002nz.jpg

 

Php script:

<?php
$sql = "SELECT winner, a.gameid, b.colour, newcolour, 
original as hero, description, kills, deaths, assists, creepkills, creepdenies, neutralkills, towerkills, gold, 
item1, item2, item3, item4, item5, item6, 
it1.icon as itemicon1, it2.icon as itemicon2, it3.icon as itemicon3, it4.icon as itemicon4, it5.icon as itemicon5, it6.icon as itemicon6, 
it1.name as itemname1, it2.name as itemname2, it3.name as itemname3, it4.name as itemname4, it5.name as itemname5, it6.name as itemname6, 
leftreason, b.left, b.name as name, e.name as banname
FROM dotaplayers AS a 
LEFT JOIN gameplayers AS b ON b.gameid = a.gameid and a.colour = b.colour 
LEFT JOIN dotagames AS c ON c.gameid = a.gameid 
LEFT JOIN games AS d ON d.id = a.gameid 
LEFT JOIN bans as e ON b.name = e.name
LEFT JOIN heroes as f ON hero = heroid
LEFT JOIN items as it1 ON it1.itemid = item1
LEFT JOIN items as it2 ON it2.itemid = item2
LEFT JOIN items as it3 ON it3.itemid = item3
LEFT JOIN items as it4 ON it4.itemid = item4
LEFT JOIN items as it5 ON it5.itemid = item5
LEFT JOIN items as it6 ON it6.itemid = item6
where a.gameid='$gid' order by newcolour";

...than

foreach ($dbHandle->query($sql, PDO::FETCH_ASSOC) as $row)
{
...
[code=php:0]$name=$row["name"];

and script to print:

<a <?php if($banname<>'') { print 'style="color:#e56879"'; } ?> href="?p=user&u=<?php print $name; ?>&s=datetime&o=desc&n=<?php if($displayStyle=='all'){ print 'all'; } else { print '0'; } ?>" target="_self"><b><?php print $name; ?></b></a>

Link to comment
Share on other sites

Thanks for reply.

 

Ok, I have change it but still can see this bugged characters. I say bugged cause that characters no one write in his name. (this strange characters sometimes appear, but not offen).

 

Also, when I change charset this I got on main page:

itemi se raÄunaju sada

insted of:

itemi se računaju sada.

 

I just wont to remove those characters if its possible (maybe script to search sql table, find and update)?

Link to comment
Share on other sites

Ok, I tried:

$name=$row["name"];
$replaceme = $name;
$name=str_replace("€", " ", $replaceme);

And its working.

Only is problem cause there is no statistic data for player who have this character (stored in mysql - with  €).

But nothing is perfect.  :)

Link to comment
Share on other sites

Yea, silly me ...unnecessary string.  :)

Too bad, its only replace output, but not table in sql.

Probably I need to change some code in program that update data in mysql (written in C++).

 

Ok...thanks JAY6390, this part is solved.

 

Link to comment
Share on other sites

You could use the REPLACE command in mysql and run it on each of the usernames

http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_replace

 

Example

UPDATE `user_table_name` SET `username_column` = REPLACE(`username_column`, '€', '')

That will replace all usernames so that they have no € in the names (change the table and column names to the ones in your table, then run the query either with a simple script or phpmyadmin

 

Link to comment
Share on other sites

It would actually be

$sql = "UPDATE `gameplayers` SET `name` = REPLACE(`name`, '€', '')";

Note that I used backticks ` around the table and column names - This is because they're identifiers not string values. You also had an extra ' at the end of your query

 

As for running this in php it's perfectly fine

Link to comment
Share on other sites

Unfortunately, solving this problem cause another  :shrug:

 

There is some empty space. Here is picture:

001at.jpg

I have selected only blank space (so its blue).

And on page:

002hf.jpg

 

I have tried this code:

$sql = "UPDATE `gameplayers` SET `name` = REPLACE(`name`, '   ', '')";
$result = mysql_query($sql);

But nothing happend. And then tried some combinations, but than all spaces in names was removed (ex. my nick -> mynick). Just need to remove few empty spaces after nick (not in middle).

 

Ok, I found here:

http://dev.mysql.com/doc/refman/5.1/en/string-functions.html

Probably need to use "LTRIM - Remove leading spaces", but not sure about it (and dont screw other nicknames).

 

EDIT2:

I think I found it:

http://dev.mysql.com/doc/refman/5.1/en/string-functions.html#function_rtrim

Link to comment
Share on other sites

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.