MySQL使用UPDATE,SET,REPLACE字符串和UTF-8格式

时间:2015-05-07 12:31:40

标签: php mysql opencart

我在下面有这段代码并且工作正常,问题是当它上升时如果我使用保加利亚字符,一切都会出现,例如СÑ,ѰнаÑ,анач уÐ'ÐμÑаÑ,Ð

但是当我用保加利亚语的管理菜单(Opencart)显示添加保加利亚的东西时。

数据库表'name'位于utf8_general_ci。

   <?php
include 'config.php';
$servername = DB_HOSTNAME;
$username = DB_USERNAME;
$password = DB_PASSWORD;
$dbname = DB_DATABASE;
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
} 

$sql = "UPDATE product_description SET name = REPLACE(name, 'The amazing spiderman Phone', 'Страната на чудесата')";

if ($conn->query($sql) === TRUE) {
    echo "Record updated successfully";
} else {
    echo "Error updating record: " . $conn->error;
}

$conn->close();
?>

0 个答案:

没有答案