ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Hi There;
As a hot volunteer of an open source initiative, I feel sorrow using MS-SQL and IIS. I could not convince boss to use mySQL, but anyway I can push PHP on boss.
I have a MS-SQL server and I have Turkish names in my table. User enters names and I send it to SQL server, print result to output. However, my PHP code process and prints text as a UTF-8, and send it to MS-SQL and print it to output.However data in MS-SQL is in Windows(Turkish) format, so there are nothing to return. For example;
when user types "Güray" in html input form, PHP issues a query:
"SELECT * FROM table WHERE name ='Güray' " and sends it to MS-SQL server. Server returns nothing, but I know that there are many entries that name attribute is 'Güray'.
But when name contains purely English characters, such as 'Ali' it works fine.
In addition, when I print result of query returned by MS-SQL via HTML , Turkish character in a string printed in a rectangle.
How can I overcome these two frustrating situations? Any help is greatly appreciated.
If the thing you've said will happen , it would be a great catastrophe
Exactly It might be a good idea to read up on preventing SQL injection attacks (there are many other sites on the web, which could be better than the one I found - search for 'preventing SQL injection' or similar in Google)
I tried every encoding recognized in PHP, but I couldn't able to print Turkish characters properly.
Here is the code that lists the encoding:
Code:
$text = "Pijamalı hasta yağız şoföre çabucak güvendi."; //Turkish "The quick brown fox jumps over the lazy dog";
foreach(mb_list_encodings() as $chr){
echo mb_convert_encoding($text, $chr)." : ".$chr."<br>";
}
Only thing I can think of is to use HTML entities:
Code:
â = â
 = Â
ç = ç
Ç =Ç
ğ = ğ
Ğ = Ğ
ı = ı
İ = İ
ö = ö
Ö = Ö
ş = ş
Ş = Ş
ü = ü
Ü =Ü
î = î
Î = Î
û = û
Û = Û
You can then search through all your text, replacing any special characters with the above entities, which should then appear correctly regardless of character set. If you're doing text comparison with your database, you'll also need to convert all your database data to use these entities as well
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.