How to work out what "SQLSTATE[HY000]: General error: 25 bind or column index out of range" actually means
I'm getting this error when using PHP's PDO to insert records into an sqlite3 database. It's only happening on some inserts. SQLSTATE[HY000]: General error: 25 bind or column index out of range Now I realise it's probably telling me that some column constraint is being contravened or maybe that I have an invaldid column name or something in the insert. However I can't work out what the error is and without some sort of pointer as to which column (or whatever) is causing the problem I'm at a bit of a loss to find the error. The insert query string being handed to the prepare() function is:- INSERT INTO log (seqno, year, month, day, hour, minute, waterway, pk, place, distance, eng_hrs, fuel_cm, fuel_lt, note, type ) VALUES (:seqno, :year, :month, :day, :hour, :minute, :waterway, :pk, :place, :distance, :eng_hrs, :fuel_cm, :fuel_lt, :note, :type ); and the execute query is being handed an array with matching keys. I'm *wondering* if the issue may be that a couple of fields have characters like '-' and ',' in them, do I need to quote or escape these maybe? -- Chris Green
On Sun, Nov 06, 2011 at 08:07:31PM +0000, Chris Green wrote:
I'm getting this error when using PHP's PDO to insert records into an sqlite3 database. It's only happening on some inserts.
SQLSTATE[HY000]: General error: 25 bind or column index out of range
Now I realise it's probably telling me that some column constraint is being contravened or maybe that I have an invaldid column name or something in the insert. However I can't work out what the error is and without some sort of pointer as to which column (or whatever) is causing the problem I'm at a bit of a loss to find the error.
The insert query string being handed to the prepare() function is:-
INSERT INTO log (seqno, year, month, day, hour, minute, waterway, pk, place, distance, eng_hrs, fuel_cm, fuel_lt, note, type ) VALUES (:seqno, :year, :month, :day, :hour, :minute, :waterway, :pk, :place, :distance, :eng_hrs, :fuel_cm, :fuel_lt, :note, :type );
and the execute query is being handed an array with matching keys.
I'm *wondering* if the issue may be that a couple of fields have characters like '-' and ',' in them, do I need to quote or escape these maybe?
Aarrgghh!! It's not funny characters, it's having a key in the array being inserted that doesn't match a column name in the INSERT. I'd added an extra field/column called 'title' and hadn't added it to the INSERT command. The error message could be a bit more helpful! Once I'd added 'title' to the insert command the error message *was* helpful and told me that there wasn't a 'title' column in the log table. -- Chris Green
participants (1)
-
Chris Green