MySQL 搜索中文乱码 (1064) You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '\xC1\xAA\xCF\xEB'
代码如下:
$keywords = $_GET['keyword];
$where = " where keywords=".$keywords;
DB::result_first("SELECT count(*) FROM DB::table('article') $where_keywords");
搜索中文时,乱码错误,如:
(1064) You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '\xD6\xD0\xCE\xC4' at line 1
SELECT * FROM article where keywords=中文
解决方案
$keywords
用单引号包裹起来,如
$where = " where keywords='".$keywords."'";