Getting \u200b

Hi Experts,

I have the following simple code
 $query = "SELECT id, name "
               . "FROM locations "
               . "WHERE id != 1 " //Loc 1 = N/A (System Record)
               . "AND archived = 0 ";
        
       if (count($exclude_locs) != 0){
           $query = $query . "AND id NOT IN ($exclude) ";
       }
        
        $query = $query . "ORDER BY name";
        
        $query = str_replace("\u200b", "", $query);

Open in new window


I am also doing an echo of $query, which returns
SELECT id, name FROM locations WHERE id != 1 AND archived = 0 ORDER BY name

Open in new window


When I copy the query from echo directly to phpMyAdmin I get a red dot before SELECT and if I dont remove it I get an error. However, when I hover my mouse over the red dot the mouse tip shows \u200b

This is why I added the str_replace, but it does not help.

I even tried replacing the double qotes with single quotes.

What wrong?
APD TorontoSoftware DeveloperAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ray PaseurCommented:
Here's what you're probably seeing.
http://www.fileformat.info/info/unicode/char/200B/index.htm

You might try using ltrim() to remove the leading character.  Or you might try preparing the statement in a separate text editor and deleting the line(s) in question from your script.  Then you can paste the newly prepared lines back into the correct places in the script.  Please do not use Notepad for this.

You may want to check your character encoding in your text editor - if any of the codings are off, it can cause some confusion.
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_11880-Unicode-PHP-and-Character-Collisions.html
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
APD TorontoSoftware DeveloperAuthor Commented:
Why not Notepad? I ask because before I read your post, I tried Notepad, then pasted back and the error persist.
0
Ray PaseurCommented:
Notepad may add Byte Order Marks to unicode documents.  It's in the article.  Another Microsoft artifact that lives on, causing programming errors for years after it has outlived its usefulness!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.