0

When I do an insert from my application all ★ (stars) turns into "★"

How can I stop this from happening?

*It works if I directly insert it through phpmyadmin, but not when doing it using this php:

<?php
$servername = "";
$username = "";
$password = "";
$dbname = "";

$inputTime = mysql_escape_string($_POST['inputTime']);
$inputBotid = mysql_escape_string($_POST['inputBotid']);
$inputImage = mysql_escape_string($_POST['inputImage']);
$inputName = mysql_escape_string($_POST['inputSkin']);
$inputStatus = mysql_escape_string($_POST['inputStatus']);
$inputTradeid = mysql_escape_string($_POST['inputTradeid']);

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
} 

$sql = "INSERT INTO items (trade, market_hash_name, status, img, botid, time)
VALUES ('$inputTime', '$inputName', '$inputStatus', '$inputImage', '$inputBotid','$inputTime')";

if ($conn->query($sql) === TRUE) {
    echo "Success";
} else {
    echo "Error: " . $sql . "<br>" . $conn->error;
}

$conn->close();
?>
Zidco
  • 23
  • 5

1 Answers1

0

You have Mojibake. Search this Q&A for 'Mojibake' to see what causes and how to prevent it.

Since you are into symbols, you might want to use utf8mb4, not just utf8 in MySQL. The former includes various 4-byte Emoji.

Also, see PHP tips. The most important is $mysqli_obj->set_charset('utf8mb4'); right after connecting.

Community
  • 1
  • 1
Rick James
  • 135,179
  • 13
  • 127
  • 222