Reputation: 4886
I have this sql query
$sql = 'SELECT id, texto FROM `db_name`.`table_name` WHERE ( CONVERT( `texto` USING utf8 ) LIKE '%q%' ) ORDER BY score DESC LIMIT 0,15';
I am getting following error
Warning division by zero at line 40
Query was empty
Although when I copy the same query to my phpmyadmin terminal for sql and do query there it gives result
Update
function get()
{
$sql = 'SELECT id, texto FROM `db_name`.`table_name` WHERE ( CONVERT( `texto` USING utf8 ) LIKE '%fincas%' ) ORDER BY score DESC LIMIT 0,15';
$rc= $this->parent->parent->database->query($sql);
$post='';
while($row= $this->parent->parent->database->readRows($rc))
{
echo $post;
echo str_replace('"','"',$row['texto']).'"'.$row['id'];
$post="\n";
}
}
Upvotes: 0
Views: 1118
Reputation: 9635
first error is your php error check the php code where you perform some math division on line 40
second error comes due to use your single quotes in sql query '%q%'
.correct it by enquote you sql string in double quotes
$sql = "SELECT id, texto FROM `db_name`.`table_name` WHERE ( CONVERT( `texto` USING utf8 ) LIKE '%q%' ) ORDER BY score DESC LIMIT 0,15";
Upvotes: 4