开发者

PHP MySQL utf 8 encoding [duplicate]

This question already has answers here: UTF-8 all the way through (13 answers) Closed last year.

My trying to make an Ajax call to a PHP function that pulls out data from my database. I've run into a problem tho开发者_如何学Pythonugh.

My query looks like this

$query = "SELECT * FROM mytable WHERE field LIKE '%$string%'"

I then check on the number of rows returned by the query, but when i type in æ ø å then i my query returns 0 rows, although I know there are entries in the database that have æ ø å.. why is this


Set the connection to use UTF-8:

<?php

// MySQLi:

$connection = new MySQLi( /* ... credentials ...*/);
$connection->set_charset("utf8");


// MySQL:
$connection = mysql_connect(/* ... credentials ... */); 
mysql_set_charset("utf8", $connection);

?>


in my case, I had to add this line:

mysqli_set_charset($con,"utf8mb4");
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜