I've been trying to do a search filter and this error continue to appear, can someone help me out?
{
require_once('conn.php');
$idata = $_POST["idata"];
$fdata = $_POST["fdata"];
$sql = "Select TOP 10* from cadcli where dtcad between $idata and $fdata";
$query = ibase_query($dbh,$sql) or die (ibase_errmsg());
while ($row = ibase_fetch_object($query)) {
echo $row->COLUNA1."n";}
ibase_free_result($query);
echo "$query";
ibase_close($dbh);
}
The problem is that Firebird doesn't know the keyword
TOP
. The equivalent in Firebird 2.5 and earlier isFIRST
. Since Firebird 3, you can also use the SQL standardFETCH
.Using
FIRST
:Using
FETCH
:Please be aware that without an
ORDER BY
, the order is not deterministic.I also notice that you are doing string interpolation in your query, which makes it vulnerable to SQL injection. I recommend that you switch to using prepared statements with parameters (see
ibase_prepare
andibase_execute
).