2

The situation: PHP 5.2.9 => FreeTDS (a CVS version of July, if I remember well) => SQL 2008 R2. PHP is on a CentOS 5.x and Sql server on Windows 2008. Really funny :)

The problem: trying to pass a VARCHAR(2000) to a stored procedure, all goes well, until the string to be passed contains some strange (ok, not so strange) characters like

, the left/right single quotes

, the left/right double quotes

  , –

In presence of these characters, the stored procedure executes well, php doesn't report any error, but the field in the db comes out containing an empty string.

Removing these offending characters, the string is correctly parsed.

What to do?

Thank you in advance.

  • 1
    I think this post should answer your question: http://stackoverflow.com/questions/1262038/how-to-replace-microsoft-encoded-quotes-in-php – Phill Pafford Nov 09 '10 at 21:00
  • Does this also happen, when passing any non-latin letters? (ex. ĀǾǔ王) – dev-null-dweller Nov 09 '10 at 21:05
  • @dev-null-dweller with your characters the resulting string is `ĀǾǔ王` I'm performing only an utf8_decode on the string before passing it to sql – ilcartolaio Nov 09 '10 at 21:12
  • If so, try @Phill Pafford solution. My guess was about charset while making connection , but since you pass only iso-8859-1 encoded strings, this should not be issue. – dev-null-dweller Nov 09 '10 at 21:27
  • The utf8_decode, was the first solution that came to my mind,but it's unuseful in this case. I'll proceed removing smart quotes – ilcartolaio Nov 09 '10 at 21:41
  • non-latin characters are automagically converted in entities even without the utf8_decode function. I think it's a freetds feature – ilcartolaio Nov 09 '10 at 22:26

1 Answers1

1

Converting Smart Quotes

Phill Pafford
  • 83,471
  • 91
  • 263
  • 383