vikac Posted November 8, 2016 Share Posted November 8, 2016 Hello, First of all sorry for bad english :-) I have some data in mysql database. Have also search box which works fine except for "special croatian signs". We have š,ž,č,ć,đ. So, š and ž works also fine but ć, č đ doesn't work. I search a little bit and change unicode to UTF8, and also add three line in conn file: mysql_query("SET NAMES utf8"); mysql_query("SET CHARACTER SET utf8"); mysql_query("SET COLLATION_CONNECTION='utf8_unicode_ci'"); But still have nothing :-( When I enter đ instead đ, search work fine. Also when i enter sql query in mysql, works fine. But thrue web search failed. This is search code: <?php if (!empty($_REQUEST['term'])) { $term = mysql_real_escape_string($_REQUEST['term']); $sql = "SELECT * FROM table WHERE name LIKE '%".$term."%' OR proiz LIKE '%".$term."%'"; $r_query = mysql_query($sql); while ($row = mysql_fetch_array($r_query)){ echo '<a href="2.php?id='.$row['id'].'">'.$row['name'].'</a>'; echo '<br /> Tel: '.$row['tel']; echo '<br /> Proiz: '.$row['proiz']; echo '<br /><br /><br /><br /> '; } } ?> Is it possible to check and replace search term if user enter đ to replace it to đ and do the search? Again appologize for bad english and lack of knowledge in php Thanks in advance Quote Link to comment https://forums.phpfreaks.com/topic/302486-how-to-change-some-characters-which-user-entered-in-search-box-pls-help/ Share on other sites More sharing options...
benanamen Posted November 8, 2016 Share Posted November 8, 2016 (edited) You have a much bigger problem. You are using obsolete insecure Mysql code that has been completely removed from Php. You need to use PDO with prepared statements. https://phpdelusions.net/pdo Edited November 8, 2016 by benanamen Quote Link to comment https://forums.phpfreaks.com/topic/302486-how-to-change-some-characters-which-user-entered-in-search-box-pls-help/#findComment-1539086 Share on other sites More sharing options...
Jacques1 Posted November 8, 2016 Share Posted November 8, 2016 If you have to search by HTML entities (like đ), there's something seriously wrong with your application or your data. Does the database itself contain those entities? Then you need to repair your data first. Make a backup and write a short script which reads the encoded text, decodes it and writes it back. And, yeah, do use PDO. The 90s are over. Quote Link to comment https://forums.phpfreaks.com/topic/302486-how-to-change-some-characters-which-user-entered-in-search-box-pls-help/#findComment-1539087 Share on other sites More sharing options...
vikac Posted November 9, 2016 Author Share Posted November 9, 2016 I knew that I would embarrass my knowledge. OK I will try to learn PDO. Jacques1, data in my database are ok (đ,č,ć) Thank you very much for reply Quote Link to comment https://forums.phpfreaks.com/topic/302486-how-to-change-some-characters-which-user-entered-in-search-box-pls-help/#findComment-1539129 Share on other sites More sharing options...
Jacques1 Posted November 9, 2016 Share Posted November 9, 2016 Jacques1, data in my database are ok (đ,č,ć) This is very hard to believe. The application must be truly fucked up to mangle the literal input “đ” into a Unicode character. And it must be even more fucked up to not accept the original character. Your claim that some characters work while other don't again indicates a data problem. I strongly recommend you check specific data records directly in the database (not with PHP). That is, search for “đ” with your web form, then look up the found rows directly in the database. If you can definitely confirm that the record is found despite not containing “đ”, we need to see your code. Is JavaScript involved? Quote Link to comment https://forums.phpfreaks.com/topic/302486-how-to-change-some-characters-which-user-entered-in-search-box-pls-help/#findComment-1539130 Share on other sites More sharing options...
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.