Answer the question
In order to leave comments, you need to log in
How to pass query from php to mysql, encoding 1252?
Hello. Faced a problem.
The data in my database uses encoding 1252 (mysql)
From php, I need to send a request to the database, for which I will recode my entry to 1252 like this:
$string = "Привет";
$string = iconv('utf-8', 'cp1251', $string);
$string = iconv('cp1252', 'utf-8', $string);
$textsql='SELECT id FROM inv_devices where staff="'.$string.'"';
$answsql=mysql_query($textsql);
$id1=mysql_result($answsql,0,0);
Warning: mysql_result() [function.mysql-result]: Unable to jump to row 0 on MySQL...
SELECT id FROM inv_devices where staff="<b>Ïðèâåò</b>"
Answer the question
In order to leave comments, you need to log in
So far, all that is visible is some kind of crookedness.
$string = iconv('utf-8', 'cp1251', $string);
$string = iconv('cp1252', 'utf-8', $string);
Maybe it will help mysql_query("set names 'utf8'");
Although it's true, it's not clear why to drive encodings back and forth.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question