Error Manual for MySQL server version for the right syntax to use near '-1%'' LIMIT 18446744073709551615' at line 1

389 Views Asked by At

getting a SQL syntax error all of a sudden:

Suddenly getting a SQL syntax error 'You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-1%'' LIMIT 18446744073709551615' at line 1'

// begin Recordset
$suggestParam__colours = '-1';
if (isset($_GET['suggest1_choice'])) {
  $suggestParam__colours = $_GET['suggest1_choice'];
}
$query_colours = sprintf("SELECT colour_name FROM colours WHERE colour_name LIKE '%s'", GetSQLValueString($suggestParam__colours . "%", "text"));
$colours = $autocomplete->SelectLimit($query_colours) or die($autocomplete->ErrorMsg());
$totalRows_colours = $colours->RecordCount();
// end Recordset 
1

There are 1 best solutions below

0
Remo Harsono On

Here's the syntax of selectLimit based on the adodb-php source at Github

SelectLimit($sql, $nrows = -1, $offset = -1, $inputarr = false, $secs = 0)

When you didn't supply $nrows parameter, it will default to -1, the function will assign 18446744073709551615 as $nrows value when the parameter is -1 (which is the default value when you don't supply that parameter).

18446744073709551615 is the maximum unsigned 64 bit integer which used to retrieve all rows