如何在mysql DB中插入希腊字符?

时间:2017-03-16 23:52:30

标签: php mysql forms mysqli webforms

我有下面的代码,我想在我的数据库表中添加希腊字符。数据库和表的编码是“utf8_general_ci”。条目显示如下:“Î'Ïα±ÏÎÎÏÏλ”。我的.php代码有什么问题吗?

    <?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "products";

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);

// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}

// Escape user inputs for security
$itemname = mysqli_real_escape_string($conn, $_REQUEST['itemname']);
$descr = mysqli_real_escape_string($conn, $_REQUEST['description']);
$image = mysqli_real_escape_string($conn, $_REQUEST['image']);
$price = mysqli_real_escape_string($conn, $_REQUEST['price']);

// attempt insert query execution

$sql = "INSERT INTO items (itemname, descr, image, price) VALUES ('$itemname', '$descr', '$image', '$price')";

if(mysqli_query($conn, $sql)){

    echo "Success.";

} else{

     echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);

}
?>

0 个答案:

没有答案