Search code examples
phpmysqlsql-limit

SELECT ... LIMIT 0,1 syntax error


    for($nr = 0; $nr < 2; $nr++){

        print $nr; print(gettype($nr));   // prints 0integer 

        $result = mysqli_query($con,"SELECT * FROM phcdl_files 
        ORDER BY file_id DESC LIMIT '$nr',1") 
        or die(mysqli_error($con));
    }

Trying to run the query above but I'm having troubles because of syntax. Running it on PhpMyAdmin with Limit 0,1 works good however

Any idea what's the problem?


Solution

  • Try with -

    "SELECT * FROM phcdl_files ORDER BY file_id DESC LIMIT $nr,1"