SSP::Complex Error

SSP::Complex Error

samjgsamjg Posts: 2Questions: 1Answers: 1

Link to test case:
Debugger code (debug.datatables.net):
Error messages shown:
DataTables warning: table id=example - An SQL error occurred: SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens
Description of problem:

I've traced the problem with the DataTables search box error I'm seeing to the SSP::complex call. When I swap that call out for SSP::simple I no longer have the error.

Error Message when I try to use the Search box: DataTables warning: table id=example - An SQL error occurred: SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens

Relevant code block:
// Custom WHERE clause for filtering data
$whereAll = "viewable = 1 AND Hidden = 0 AND isPublic = 1";

// Output data as JSON
echo json_encode(
SSP::complex($_GET, $sql_details, $table, $primaryKey, $columns, null, $whereAll)
);

PHP Version (From YUM list):
php.x86_64 7.2.24-1.module+el8.2.0+5510+6771133c

This question has an accepted answers - jump to answer

Answers

  • samjgsamjg Posts: 2Questions: 1Answers: 1
    Answer ✓

    Found the issue. There is a line in the SSP scripts file for the SSP::complex function that has bad line in it. The call is trying to send binds to a SQL request that isn't expecting any bindings and that was creating an SQL error. So I replaced the line with a line that wasn't sending any bindings.

    Old: $resTotalLength = self::sql_exec( $db, $bindings,
    New: $resTotalLength = self::sql_exec( $db, null,

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    That's an interesting one. Because sometimes you might want the bindings to be passed through! Good to hear you have a workaround though.

    To be honest, the SSP script is really only a demo. If you want scripts which are production ready, I'd suggest looking at the Editor PHP libraries they are open source and can be used without an Editor license.

    Allan

Sign In or Register to comment.