Solved

PHP MySQL query  spaces become: T T T T T

Posted on 2014-12-31
4
126 Views
Last Modified: 2015-01-04
I'm using Ajax to query the database and display the text on a page.   If the text in the database has spaces for example:

"text                                   text."

it becomes:

"textТ Т Т Т Т Т Т Т Т Т Т Т Т Т Т Т Т Т Т Т Т Т Т Т Т Т Т Т Т Т Т Т Т Т Т text"

If I then submit that it becomes this:

textаЂТ аЂТ аЂТ аЂТ аЂТ аЂТ аЂТ аЂТ аЂТ аЂТ аЂТ аЂТ аЂТ аЂТ аЂТ аЂТ аЂТ аЂТ аЂТ аЂТ аЂТ аЂТ аЂТ аЂТ аЂТ аЂТ аЂТ аЂТ аЂТ аЂТ аЂТ аЂТ аЂТ аЂТ аЂТ  text

I can't find anything online that explains this behavior.  

Even if I do a string replace in Javascript I can't get rid of it.   I can change the t in text or the e or the word text.  But If I try to replace the /T /  nothing will happen.  

I think it may be some kind of Unicode character
0
Comment
Question by:vrosas_03
4 Comments
 
LVL 84

Expert Comment

by:ozo
Comment Utility
Can you post the code that does the query and display?
0
 
LVL 61

Expert Comment

by:gheist
Comment Utility
There are no unicode characters in your firt or second string.
0
 
LVL 108

Accepted Solution

by:
Ray Paseur earned 500 total points
Comment Utility
This is a mystery that may be explained by a character-encoding mismatch.  This string appears to be valid UTF-8:
textаЂТ аЂТ аЂТ аЂТ аЂТ аЂТ аЂТ аЂТ аЂТ аЂТ аЂТ аЂТ аЂТ аЂТ аЂТ аЂТ аЂТ аЂТ аЂТ аЂТ аЂТ аЂТ аЂТ аЂТ аЂТ аЂТ аЂТ аЂТ аЂТ аЂТ аЂТ аЂТ аЂТ аЂТ аЂТ  text

That leads me to believe that each blank was somehow transformed into "аЂТ " which is something I have never seen before, and I've seen a lot.

The hexadecimal values of this string are: "d0 b0 d0 82 d0 a2 20"

The d0 b0 renders the letter "a"
The d0 82 renders this thing "Ђ"
The d0 a2 renders the letter "T"
And the 20 renders the trailing blank

Maybe if you can show us the original data and some of the programming we can help figure out where the transformation is occurring.  You may also want to check your character-set encoding for consistency throughout.
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_11880-Unicode-PHP-and-Character-Collisions.html
0
 

Author Closing Comment

by:vrosas_03
Comment Utility
I'm working with an editable div and sending the data using jQuery.ajax.   It was confusing because the problem appears to have happened in two separate ways.  First I would see the T's in firebug in the ajax post variable.  It would appear as &\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 as the response.    The spaces would appear in the phpmyadmin as just spaces with no problems.   But when I would call it from the database it would appear as T's   After getting it from the database I used the preg_replace ord command to isolate the character which turned out to be 194  which in the extended ascii character set is used to create boxes and it's shaped like a T so I guess it's to create adjoining boxes.   I used this expression to get rid of it:
$event->body = preg_replace('/\xC2/', "", $event->body)
The spaces were still there.  For some reason it's like there is a regular expression going on behind the scenes adding adding an extra character.     It seems like a character set problem.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
php documentation 4 19
Page showing diff display 4 19
CSS Divs in Safari 3 18
Retrieve values of an HTML form using JQUERY 2 11
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to count occurrences of each item in an array.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now