|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #56506 General error: 25 bind or column index out of range
Submitted: 2005-08-23 08:03 UTC Modified: 2005-08-24 07:54 UTC
From: tuupola at appelsiini dot net Assigned:
Status: Not a bug Package: PDO_SQLITE (PECL)
PHP Version: 5_1 CVS-2005-08-23 (dev) OS: Solaris 10
Private report: No CVE-ID:
 [2005-08-23 08:03 UTC] tuupola at appelsiini dot net
Prepared UPDATE queries seem to die with with error "SQLSTATE[HY000]: General error: 25 bind or column index out of range". Same query called directly via query() works.

Reproduce code:

the second one is the same code but without the prepared UPDATE query. This one works without error:

Expected result:
No errors.

Actual result:
Exception: SQLSTATE[HY000]: General error: 25 bind or column index out of range


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2005-08-23 21:45 UTC]
Please paste working code; I can't reach the links you posted.
 [2005-08-24 03:07 UTC] tuupola at appelsiini dot net
This is the code which generates error:


try {
    $dbh = new PDO('sqlite:/' . getcwd() . DIRECTORY_SEPARATOR . 'test.db');


    $dbh->query("CREATE TABLE person (
                 id INTEGER PRIMARY KEY NOT NULL,
                 firstname VARCHAR(32),
                 lastname VARCHAR(32),
                 mobile VARCHAR(16))"

    $stmt = $dbh->prepare("INSERT INTO person
                           (firstname, lastname, mobile) 
                           (:firstname, :lastname, :mobile)"

    $params['firstname'] = 'A';
    $params['lastname'] =  'A';
    $params['mobile'] =    '1';


    $params['firstname'] = 'B';
    $params['lastname'] =  'B';
    $params['mobile'] =    '2';

    $params['firstname'] = 'C';
    $params['lastname'] =  'C';
    $params['mobile'] =    '3';



sqlite> SELECT * FROM person;

    $stmt = $dbh->prepare("UPDATE person 
                           SET firstname=':firstname', 
                           WHERE (id=2)"

    $params['firstname'] = 'X';
    $params['lastname'] =  'X';
    $params['mobile'] =    '9';


} catch (PDOException $e) {
    print 'Exception: ' . $e->getMessage() . "\n";

 [2005-08-24 03:18 UTC] tuupola at appelsiini dot net
Forgot to mention. PDO and PDO sqlite are 0.9-beta from pecl. PHP itself is few days old snapshot of 5.1. The problem was also verified with PHP 5.0.4 and PDO 0.9 (some linux).
 [2005-08-24 07:54 UTC]
You've made a mistake on your update code.  You should remove the quotation marks from around the :params, otherwise sqlite sees a query with no parameters, and when you supply them, you get that error message.

$stmt = $dbh->prepare("UPDATE person 
                           SET firstname=:firstname, 
                           WHERE (id=2)"
PHP Copyright © 2001-2015 The PHP Group
All rights reserved.
Last updated: Fri Nov 27 20:01:35 2015 UTC