Search code examples
phpmysqllevenshtein-distance

levinshtein distance in mysqli prepared statement


I have the following mysqli prepare statement:

$incity = "%{$mysqli->real_escape_string($city)}%";
$instreet = $mysqli->real_escape_string($street);
$incp = "%{$mysqli->real_escape_string($cp)}%";

$mysqli->prepare("SELECT zonasrepartoid, calle, municipio, codigopostal FROM zonasreparto WHERE municipio like ? AND levenshtein(?, calle) BETWEEN 0 AND 6 AND codigopostal like ?")

$stmt->bind_param('sss',$incity,$instreet,$incp);
$stmt->execute();

My problem is that the levenshtein function doesnt return any result, and i have tried and look for anything, but i dont know what else to do.

thank you in advance!


Solution

  • I think that my problem is that i cant execute functions because i get the next message:

    Fallo en la obtencion de resultados: () execute command denied to user 'sec_user'@'localhost' for routine 'database.levenshtein'

    I hope to help to someone with the same error