Jump to content

Recommended Posts

Ok. I solved .php part on this topic:

http://www.phpfreaks.com/forums/index.php/topic,287631.0.html

 

but now cant make this sql code to work:

$sql = "UPDATE `gameplayers` SET `name` = RTRIM(`name`)";

 

Problem is to remove empty spaces at end of name and this script above is not working. DATATYPE is varchar(15)

Link to comment
https://forums.phpfreaks.com/topic/191846-rtrim-function-not-working/
Share on other sites

hmm I am a bit afraid that this will screw up your data maybe you cold cretae some temporary field tmp_name just in case

since I coulnd find alternative with mysql functions I can suggest do it with php

$qr = mysql_query("SELECT * FROM `gameplayers`");
while($row = mysql_fetch_assoc($qr))
{
  $id = $row['id'];
//I asume that valid names are only from A-Z0-9 _ . - chars
  $new_name = preg_replace('/^([a-z0-9_-\.]+)/im','\\1', $row['name']);

  //if didint create new tmp field use this
  //mysql_query("UPDATE `gameplayers` SET `name`='$new_name' WHERE `id`=$id LIMIT 1");
  //or if u cretaed just in case
  mysql_query("UPDATE `gameplayers` SET `tmp_name`='$new_name' WHERE `id`=$id LIMIT 1");
}

You have a character encoding problem.  Those are not space characters as can be seen from your own screenshot.  Look at the 2nd place you display the name, and notice the FF/FD boxes.  This leads to all sorts of questions like: what is the charset of the page that is rendered (UTF-8?) and does this match the character set used in the mysql table?

You have a character encoding problem.  Those are not space characters as can be seen from your own screenshot.  Look at the 2nd place you display the name, and notice the FF/FD boxes.  This leads to all sorts of questions like: what is the charset of the page that is rendered (UTF-8?) and does this match the character set used in the mysql table?

Exactly. That was my problem. When I changed charset to ISO-8859-1, I get this character: ®

 

And I used this code:

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

And Its working (removed FF/FD), but now I have really empty space.

This makes 2 different users.

First (HTML link created for that user) - with space:

?p=user&u=l@dy%20ev@%A0%A0%A0&s=datetime

Second (w/o empty space):

?p=user&u=L@dy Ev@&s=datetime

Well, this is for you to decide. However, it seems that your issue is not with the data but rather with your mismatched database character set to the one you are claiming to use when you render your pages.  If the mysql charset is 8859-1 then you should emit that as the charset for your page, rather than claiming to use utf-8 which in fact you aren't using.

 

Once you do that, the characters that are in there -- which are valid 8859-1 characters, will display fine, and you'll not have an issue.

 

Otherwise, what you are doing is basically making sure that those users you are changing are not going to be logging in again, because you destroyed the username they had been using.

 

 

This how it works. I used some program (written in c++) for update mysql and it seems that program makes this "bug", cause users didnt write this character.

 

I set charset for pages to 8859-1, but in mysql collation is: utf_general_ci

I'm not sure how to remove this "empty space" or strange characters (or I need to change some code in program, but thats different story)?

 

Thanks for reply.

Collation and character set are 2 different things.  Can you verify for the user table what the character set is.  Please do this from mysql or phpmyadmin sql window:

 

SHOW CREATE TABLE tablename;

 

tablename should be your user table name, whatever that is.  Then paste the contents in a reply.

Here it is:

CREATE TABLE `gameplayers` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`botid` int(11) NOT NULL,
`gameid` int(11) NOT NULL,
`name` varchar(15) NOT NULL,
`ip` varchar(15) NOT NULL,
`spoofed` int(11) NOT NULL,
`reserved` int(11) NOT NULL,
`loadingtime` int(11) NOT NULL,
`left` int(11) NOT NULL,
`leftreason` varchar(100) NOT NULL,
`team` int(11) NOT NULL,
`colour` int(11) NOT NULL,
`spoofedrealm` varchar(100) NOT NULL,
PRIMARY KEY (`id`),
KEY `gameid` (`gameid`),
KEY `gameid_2` (`gameid`),
KEY `colour` (`colour`),
KEY `name` (`name`),
KEY `gameid_3` (`gameid`),
KEY `colour_2` (`colour`),
KEY `name_2` (`name`),
KEY `gameid_4` (`gameid`),
KEY `colour_3` (`colour`),
KEY `name_3` (`name`),
KEY `gameid_5` (`gameid`),
KEY `colour_4` (`colour`),
KEY `name_4` (`name`)
) ENGINE=MyISAM AUTO_INCREMENT=12363 DEFAULT CHARSET=latin1

Ok, so as I stated, your table is "DEFAULT CHARSET=latin1".  For all intents and purposes, latin1 = 8859-1.

 

I question that your page is actually setting the charset to be 8859-1.  You should probably double check your assumptions.

 

This page might be helpful, in case anything is unclear.  http://en.wikipedia.org/wiki/ISO/IEC_8859-1#ISO-8859-1

 

 

Ok, I have read this page on wiki and still can figure how to fix this.

 

Here is image with listing (I have selected second row where is "empty" char in nickname)

002jok.jpg

First and third nickname in gamelist is fine.

 

But it seems that I cant fix it for latin1 charcode (I must look deeper into program code that update data).

Using some sort of header checking tool like Firebug, open up your page and look at the headers.

 

For latin-1 it should be:

 

Content-Type: text/html; charset=ISO-8859-1.

 

If you want to PM me the url (assuming you don't want to post it) of your site, I can take a look as well.

 

Summary:  check the code that emits the http headers for your site.  If this is not being set in the header, then I'd expect that the pages would have a header section like:

 

 

Something tells me that what you actually have is charset=utf-8

 

 

 

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.