gpt4 book ai didi

php - 非英语不支持来自 $.post jquery codeigniter 的 mysql 查询

转载 作者:行者123 更新时间:2023-11-29 15:29:30 24 4
gpt4 key购买 nike

我需要通过 $.post 调用 ajax 以获取非英语关键字,但它最终以编码格式结束,因此没有结果。我的编码为 UTF-8,数据库排序规则为 utf8_unicode_ci。仍然有问题。分享代码和结果:

//Jquery

$('form#frm_word').submit(function (e) {
e.preventDefault();
//var url = $(this).attr('action');
var s = $('input#s').val();
var url = '<?php echo site_url('words/get_word'); ?>' + '/' + s;
$.post(url, function (o) {
if (o.result == 1) {
console.log(o.words);
}
}, 'json');
});

Case url: http://localhost/subscription/words/get_word/আমি
Result: SELECT * FROM `words` WHERE w_word LIKE
'%%E0%A6%86%E0%A6%AE%E0%A6%BF%'{"result":2}

最佳答案

使用段函数(如$this->uri->segment(3))获取变量中的值,然后在查询中使用引号发送参数,如

select * from words where w_word LIKE '$variable%'; 
or
select * from words where w_word = '$variable';

关于php - 非英语不支持来自 $.post jquery codeigniter 的 mysql 查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58830656/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com