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 TorontoAsked:
Who is Participating?
 
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
 
APD TorontoAuthor 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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.