0
I am developing a feature on my site to show similar properties by title and value 9r, but it did not work very well my idea:
<?php
//Armazeno o resultado do titulo da consulta anterior da tabela imoveis em um variável
$titulo_semelhante = $results['titulo'];
//Armazeno o resultado do valor do imóvel da consulta anterior em um variável
$valor_semelhante = $results['venda'];
//Realizo uma nova consulta, onde o titulo na tabela vw_exibir contenha a palavra da variavel $titulo_semelhante e contenha um valor menor ou igual a variavel $valor_semelhante
$q2 = $db->query("SELECT * from vw_exibir WHERE titulo LIKE '%$titulo_semelhante%' AND venda <= '".$valor_semelhante."' ");
foreach($q2 as $row){
print_r($row);
}
?>
Always returns me that mistake:
<b>Fatal error</b>: Problem preparing query (SELECT * from vw_exibir WHERE titulo LIKE '%Apartamento em Balneário Camboriú%' AND venda ) Você tem um erro de sintaxe no seu SQL próximo a ''%Apartamento em Balneário Camboriú%' AND venda' na linha 1 in <b>/home/himoveis/www/includes/MysqliDb.php</b> on line <b>447</b><br />
Can anyone tell me if I am developing this feature correctly, and why this error is returning?
OBS:
I use class - PHP-Mysqli-Database-Class When I do the same query with static values in phpmyadmin all this ok:
ex:SELECT * from vw_exibir WHERE titulo LIKE '%Apertamento%' AND venda <= 1500000
Try to use
$db->prepare('Sua query');
and right after use$q2->execute()
– RFL
@Rafaelacioly, I tried and had this return: <b>Fatal error</b>: Call to Undefined method Mysqlidb::prepare() in <b>/home/***/www/exclusive/tpl/imovel.php</b> on line <b>225</b><br />
– Igor Silva
go to your location -> PHP -> PHP Extension -> and select
php_pdo_mysql
– RFL
Already this in the hosting server, Pdo this active.
– Igor Silva
Put the code snippet that was wrong.
– RFL
I would say that your problem is the encoding, probably your current encoding does not allow certain characters. You are extracting that value from an ajax request?
– Wilson -
Igor, to do this it may be necessary to change your modeling. Can you ask the question the modeling of your tables that involve this search? On the basis of this information I will draw up a public utility response.
– KaduAmaral
$db->query
'is a custom method? Because the html entities that appeared make me believe that Oce created a method of his own and used htmlspecialchars or htmlentities. I could give you more details of your codido?– Guilherme Nascimento