1

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);


}
1
  • What is the error? Commented Oct 13, 2020 at 19:43

1 Answer 1

1

The problem is that Firebird doesn't know the keyword TOP. The equivalent in Firebird 2.5 and earlier is FIRST. Since Firebird 3, you can also use the SQL standard FETCH.

Using FIRST:

select first 10 * from cadcli ... 

Using FETCH:

select * from cadcli ... fetch first 10 rows only

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 and ibase_execute).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.