I have an sql database with sql_latin1_general_cp1_ci_as collation.
the database will contain about 3 language (English,Turkish,Arabic).
At the main page I set the charset to utf-8 as:
header('Content-Type: text/html; charset=UTF-8');
<meta charset="utf-8">
And I use this code in my php page:
$sql_server = "server";
$sql_user = "user";
$sql_password = "password";
$sql_database = "database";
$sql_conn_string = 'Driver={SQL Server};Server='.$sql_server.';Database='.$sql_database.';';
if ($sql_conn = odbc_connect($sql_conn_string, $sql_user, $sql_password)){
echo 'Connected';
$name = $_POST['cust_name'];
if (odbc_exec($sql_conn,"INSERT INTO inv01 (cust) VALUES (N'".$name."')")){
echo 'is inserted';
}
else{
echo 'is not inserted';
}
odbc_close($sql_conn);
}
else{
echo 'Connection Error';
}
When I enter an English words there is no problem
But when I use the other languages the words is inserted as unclear characters
I tried to use iconv but it's not working
$name = iconv("UTF_8","Windows-1252",$name);
//and
$name = iconv("UTF_8","UCS-2LE",$name);
What is the best collation in my case if sql_latin1_general_cp1_ci_as is not, and is there another solution without change the collation
I hope that my question is not repeated because I have read many questions here and I have not found a correct answer.
Thanks.