E se no campo de busca você colocar a palavra com acento? Funciona?
finciona, por conta da segunda parte da query
...or nome like '%$busca2%'...
sem ela, nao funciona tambem (por isso eu mantive a redundância)
bem bizarro
fiz uma pagininha de testes rapida
<?
$conexao = mysql_connect("localhost", "xxxxxxxx", "xxxx");
mysql_select_db("xxxxxx", $conexao);
$queryc="select nome from wfp_produtos where (HTMLENTITIES_DECODE(nome) like '%$_GET[busca]%')";
echo $queryc;
$consultapagina = mysql_query($queryc, $conexao);
echo "<br>Numero de resultados: ".mysql_num_rows($consultapagina);
?>
mandando pra pagina a string a ser buscada por GET
"dalma" retorna o numero de resultados: 8, no caso
"dalmatica" retorna zero
contudo, copiando o $queryc que o echo printa e colando na execuçao de sql do phpmyadmin, acha os 8 resultados
/***************************/
resolvido...
em vez de substituir os entities pelos caracteres acentuados, eu fiz
DELIMITER //
CREATE FUNCTION HTMLENTITIES_DECODE (s varchar(255)) RETURNS varchar(255) DETERMINISTIC NO SQL
BEGIN
SET s = REPLACE(s, 'À','A') ;
SET s = REPLACE(s, 'Á','A') ;
SET s = REPLACE(s, 'Â','A') ;
SET s = REPLACE(s, 'Ã','A') ;
SET s = REPLACE(s, 'Ä','A') ;
SET s = REPLACE(s, 'Å','A') ;
SET s = REPLACE(s, 'Ç','C') ;
SET s = REPLACE(s, 'È','E') ;
SET s = REPLACE(s, 'É','E') ;
SET s = REPLACE(s, 'Ê','E') ;
SET s = REPLACE(s, 'Ë','E') ;
SET s = REPLACE(s, 'Ì','I') ;
SET s = REPLACE(s, 'Í','I') ;
SET s = REPLACE(s, 'Î','I') ;
SET s = REPLACE(s, 'Ï','I') ;
SET s = REPLACE(s, 'Ñ','N') ;
SET s = REPLACE(s, 'Ò','O') ;
SET s = REPLACE(s, 'Ó','O') ;
SET s = REPLACE(s, 'Ô','O') ;
SET s = REPLACE(s, 'Õ','O') ;
SET s = REPLACE(s, 'Ö','O') ;
SET s = REPLACE(s, 'Ù','U') ;
SET s = REPLACE(s, 'Ú','U') ;
SET s = REPLACE(s, 'Û','U') ;
SET s = REPLACE(s, 'Ü','U') ;
SET s = REPLACE(s, 'Ý','Y') ;
SET s = REPLACE(s, 'à','a') ;
SET s = REPLACE(s, 'á','a') ;
SET s = REPLACE(s, 'â','a') ;
SET s = REPLACE(s, 'ã','a') ;
SET s = REPLACE(s, 'ä','a') ;
SET s = REPLACE(s, 'å','a') ;
SET s = REPLACE(s, 'ç','c') ;
SET s = REPLACE(s, 'è','e') ;
SET s = REPLACE(s, 'é','e') ;
SET s = REPLACE(s, 'ê','e') ;
SET s = REPLACE(s, 'ë','e') ;
SET s = REPLACE(s, 'ì','i') ;
SET s = REPLACE(s, 'í','i') ;
SET s = REPLACE(s, 'î','i') ;
SET s = REPLACE(s, 'ï','i') ;
SET s = REPLACE(s, 'ñ','n') ;
SET s = REPLACE(s, 'ò','o') ;
SET s = REPLACE(s, 'ó','o') ;
SET s = REPLACE(s, 'ô','o') ;
SET s = REPLACE(s, 'õ','o') ;
SET s = REPLACE(s, 'ö','o') ;
SET s = REPLACE(s, 'ù','u') ;
SET s = REPLACE(s, 'ú','u') ;
SET s = REPLACE(s, 'û','u') ;
SET s = REPLACE(s, 'ü','u') ;
SET s = REPLACE(s, 'ý','y') ;
RETURN s;
END;
//
DELIMITER;
e mantive a redundancia da busca, caso o usuario tenha digitado acentos
Edição feita por: Stormbringer, 22/12/2010, 15:21.