%EB%A5%BC%20%EB%B3%B4%EB%82%B4%EB%8A%94%20%EB%AC%B8%EC%A0%9C.png)
mydatabase 테이블에 라틴어 문자를 표시하는 데 문제가 있습니다. (ã,õ,á,é,í,…). 저는 Apache 2.4.9 및 MySQL 5.6.17과 함께 WAMP 서버를 사용하고 있습니다.
HTML로 만든 간단한 양식이 있고 쿼리를 실행하고 계정을 만드는 PHP 코드가 있습니다. PHP 코드는 다음과 같습니다.
include('config.php'); //My database data for connection
if(isset($_POST['submit'])) {
$username = $_POST['username'];
$password = $_POST['password'];
$email = $_POST['email'];
$query = "INSERT INTO account SET username = '".$username."', password = PASSWORD('".$password."'), email = '".$email."'";
$execute_query = mysqli_query($connection, $query);
if($execute_query) {
//Creates the account
}
else {
//If an error occures
}
}
예를 들어, 이제 다음을 사용하여 계정을 만듭니다.
Username: Luís
Password: 1234
E-mail: [email protected]
표를 확인하면 생성된 계정이 표시되지만 사용자 이름은 표시됩니다.루이스대신에루이스.
내가 시도한 것들:
Creating a DataBase and Table with:
utf8_general_ci
utf8_unicode_ci
utf8mb4_general_ci
utf8mb4_unicode_ci
latin1_swedish_ci
그들 중 누구도 일하지 않았어, 항상 그걸 보여주네ㅏ대신에나.
답변1
"SET NAMES utf8" 쿼리 관련 문제를 해결했습니다.
include('config.php'); //My Database data for connection.
//Connection set with $connection = mysqli_connect($mysql_host, $mysql_user, $mysql_pass, $mysql_db)
if(isset($_POST['submit'])) {
$username = $_POST['username'];
$password = $_POST['password'];
$email = $_POST['email'];
$connection->query("SET NAMES utf8"); //FIXED (Gets $connection from config.php and runs the query "SET NAMES utf8")
$query = "INSERT INTO account SET username = '".$username."', password = PASSWORD('".$password."'), email = '".$email."'";
$execute_query = mysqli_query($connection, $query);
if($execute_query) {
//Creates the account
}
else {
//If an error occures
}
}
감사합니다답변에 도움을 주신 @Giacomo1968, 결국 데이터베이스 테이블에는 아무런 문제가 없었습니다.
내 데이터베이스와 테이블은 CHARSET=utf8
및 COLLATE=utf8_unicode_ci
.