suzie 4 Posted August 16, 2011 Report Share Posted August 16, 2011 Dear, in Mysql database with collation utf8, I inserted arabic data, after retreiving them using php with charset=utf-8I used mysql_query("set names utf8"); the problem is solvedis there an alternative for this query if we are reading from mssql..thank you Quote Link to post Share on other sites
boen_robot 107 Posted August 16, 2011 Report Share Posted August 16, 2011 In MS SQL, unicode strings are stored with separate types (nchar, nvarchar, etc.), so there's no need to do that.BTW, using mysql_set_charset() is really the appropriate way to set UTF-8 charset, unless you're using a PHP version earlier than 5.2.3. Quote Link to post Share on other sites
suzie 4 Posted August 16, 2011 Author Report Share Posted August 16, 2011 Thank you for your reply, am usind the types, nchar, ntext, etc... but when retreiving data they appear as questions marks..am using php, and the charset of the page is utf8,any help please???? Quote Link to post Share on other sites
boen_robot 107 Posted August 16, 2011 Report Share Posted August 16, 2011 Which API are you accessing MS SQL with (PDO, sqlsrv extension...)? Quote Link to post Share on other sites
suzie 4 Posted August 16, 2011 Author Report Share Posted August 16, 2011 am using ODBC connection$sqlconnect=odbc_connect($db,$username,$password); Quote Link to post Share on other sites
boen_robot 107 Posted August 16, 2011 Report Share Posted August 16, 2011 I'd strongly reccomend that you switch to either PDO or the sqlsrv extension. It's pretty trivial with them.For ODBC... you could try adding ;CharacterSet=UTF-8 to your connection string, but I have no idea if it would work. Quote Link to post Share on other sites
suzie 4 Posted August 16, 2011 Author Report Share Posted August 16, 2011 do not know where to put it exactly "CharacterSet=UTF-8"please can u give me more detailsand what about PDO, it works..I'd never use it Quote Link to post Share on other sites
boen_robot 107 Posted August 16, 2011 Report Share Posted August 16, 2011 Add it at the end of the value of the $db variable (that's really your connection string). What's its current value anyway? Quote Link to post Share on other sites
suzie 4 Posted August 16, 2011 Author Report Share Posted August 16, 2011 like that:$sqlconnect=odbc_connect($db,$username,$password,CharacterSet=UTF-8); Quote Link to post Share on other sites
boen_robot 107 Posted August 16, 2011 Report Share Posted August 16, 2011 I said the $db variable, not the odbc_connect() function...Find the place where you have "$db =". It should look something like: $db = 'Server=localhost;Database=whatever_the_name_of_your_database_is'; Add ";CharacterSet=UTF-8", i.e. turn it into: $db = 'Server=localhost;Database=whatever_the_name_of_your_database_is;CharacterSet=UTF-8'; Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.