2017-10-01 3 views
1

검색 입력 GET/POST 데이터하지 내가 정렬 utf8_unicode_ci와 m의 MySQL 데이터베이스에서 태국어 함량이

내가 사용했던 나의 웹 페이지에 올바르게 표시하려면 다음을

<head> 
<meta http-equiv="Content-Type" content="text/html" charset="UTF-8" /> 
<style type="text/css"> 
.thai { 
font-family:Tahoma, Arial Unicode MS; 
font-size: 2em; 
</style> 
</head> 
<body> 
<div id="content"><span class="thai"><?php echo $row['description2'];?></span></div> 

내 DB 연결 파일은 다음과 같은 코드 있음

mysqli_query($connection, "SET NAMES UTF8"); 

지금 문제가 올바르게 표시입니다,하지만 내 검색 상자가 그것을 내가를 검색 할 수 없습니다 F 누군가가 태국어에서 검색하려고하지만 다음 데이터베이스

의 영어 콘텐츠 현재 제대로 검색하면 형식으로, 함수 utf8_decode 태국 문자의 변환을 지원하지 않습니다

<form method="GET" action="index.php" accept-charset="UTF-8"> 
<input class="thai" type="text" charset="UTF-8" class="keyword" value="Search" name="search" id="q" onFocus="if(this.value==this.defaultValue) this.value='';" onBlur="if(this.value=='') this.value=this.defaultValue;" /><br /> 

</form> 

<?php 
require_once('inc/connect.php'); 

//NOT SURE IF THE FOLLOWING DECODING IS MAKING ANY SENSE, I still Get the -No result found- for thai language, but it made the boolean error go away 

$search1=$_GET['search']; 
$search=utf8_decode($search1); 

$select1="SELECT * FROM products where id like '%$search%' || title like '%$search%' || size like '%$search%' ||description1 like '%$search%'|| description2 like '%$search%' order by id asc"; 



$result=mysqli_query($connection, $select1); 
    $num=mysqli_num_rows($result); 
if($num > 0) 
{ 
    while($row=mysqli_fetch_array($result)) 

    { 
    $oid=$row['id']; 

echo $row['title']; 




    } 
    } 
else{ 
    $ertx="No Records Found In Database"; 
echo $ertx; 
} 
?> 

답변

0

검색 내 코드입니다 PHP에서는 ISO-8859-1로 변환됩니다.이 문자 세트는 ASCII 문자이므로 타이 문자를 지원하지 않습니다.

즉 태국어 문자가 "?"로 바뀝니다. 물음표가있는 항목이 없으면 아무 결과도 찾을 수 없습니다.

참조 : http://php.net/manual/en/function.utf8-decode.php

부울 오류가 발생 했습니까? 이것은 지역 사회가 귀하의 문제에 대한 해결책을 찾는 데 도움이 될 것입니다.

사용 :

error_reporting(E_ALL); 
ini_set('display_errors', 1); 

는 PHP 런타임 오류

있게

편집 :이 대신 https://stackoverflow.com/a/22582272/5287820

+0

에서

if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); //you need to exit the script, if there is an error exit(); } 

: 는 mysqli 오류를 얻기 위해이 코드를 사용해보십시오 $ se arch1 = $ _ GET [ '검색']; $ search = utf8_decode ($ search1); 그냥 사용하는 경우 $ search = $ _GET [ '검색']; 부울 오류가 throw됩니다. –

+0

부울 오류가 발생한 코드의 위치를 ​​알고 있습니까? – wpgbrown

+0

error_reporting (E_ALL)을 사용하여 오류를 활성화하면이 오류를 찾을 수 있습니다. ini_set ('display_errors', 1); – wpgbrown