This is my code:
odbc_exec($conn,"SET client_encoding='UTF-8'");
$viewTablo= odbc_exec($conn,"SELECT A FROM B WHERE A='ÇŞÖ'");
Odbc execute doesn’t work with that ‘ÇŞÖ’ or any other Turkish character. How do I fix this?
Edit: I cannot change anything inside the database.
Code below is working.
else if ($i==23 && odbc_result($viewTablo,$i)=="(Seçilmemiş)")
{
echo '
<td>
<p class="text-xs text-center font-weight-bold mb-0"></p>
</td>';
Seems like it brings the result in utf-8 (or anything working) ,but anything I type on the .php file / input given inside the odbc_exec is not utf-8 (or whatever it needs) .
Besides, queries are working on the database itself.
I am open to any alternative to insert a ‘ÇŞÖ’ as parameter to database.
Thanks in advance.
4
Answers
Can you try with the following added?
Have you checked that the database, database table, and the column are all UTF-8? This is crucial for it to work. These two queries does that:
Also, the file has to be UTF-8, and the old trick of using Notepad in windows to open the file and then go to File->Save as..->Choose UTF-8 in the "Ecoding" dropdown that should be on the left side of the "Save" button.
Another thing that may be just an oversight, is that in your query you use A=’ÇŞÖ’ meaning it has to be exactly that, but it seems better here to use "A LIKE ‘%ÇŞÖ%’"
Edit:
For HANA, the SQL is similar:
Just make sure the NVARCHAR lenght is the same as your current.
I have not used hana but based on some searches these are things are found that may work.
try these strings as query and see if they work.
if you can change column type you can check this: insert a UTF-8 value into a SAP HANA database
Also from back of my head you can check if your php file has BOM enabled. https://stackoverflow.com/questions/2223882/whats-the-difference-between-utf-8-and-utf-8-with-bom#:~:text=There%20is%20no%20official%20difference,string%20from%20the%20file%2Fstream.
Have you tried manually specifying a connection string (DSNless) using the necessary values from the specification for the database?
PHP will accept a DSNless connection, directly entered into the first argument of the
odbc_connect
command, as per the documentation.From there, compare notes with the documentation for the connection for SAP HANA to build the connection string. You should be able to set your language and character set details directly.