Strange characters being inserted into SQL Server 2005 in place of normal ones, PHP

Reviewing the contents of a database on SQL Server 2005, I've found completely at random, strange characters often in place of the single quote. I have the single quote escaped as anyone would by replacing it with regular expressions with two single quotes.  The last one I've found I'm wondering if it because used an accented character it is "exposé", is this because they used an accented e? That is what I would assume had I not found similar strange character combinations where single quotes should be in many records, but not all, even the same word in the same field.

It is being sent POST data to PHP 5, I've gone through the script and I don't use htmlentities etc.

Any ideas?
justinvoelsAsked:
Who is Participating?
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.

BenMorelCommented:
Hi,
That seems to be an utf-8 (multi-byte) encoding.
You have to convert it to latin1 if this is your native encoding (french ?), or update your database/table encodings accordingly !
Regards,
Ben
0
LordOfPortsCommented:
MS SQL Server uses the UCS-2 encoding scheme for Unicode, try using the mb_convert_encoding PHP function http://www.php.net/mb_convert_encoding to convert the data encoding before you insert it into the database, e.g.:

// Convert encoding to USC-2 before storing the data into the database
$sText = mb_convert_encoding($sText, "UCS-2", "UTF-8");

Then when you retrieve the data from the database convert it back to UTF-8:

$sText = mb_convert_encoding($sText, "UTF-8", "UCS-2");

The unusual character you noticed instead of a single quote might potentially be the apostrophe from Microsoft Word.
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
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.