DB Error: mismatch (in a PHP script)

August 28, 2007

If you get something like the “DB Error: mismatch” message in a PHP script, this is probably caused by a bug in the script. If I get it right, the message means: there is a mismatch between the number of placeholders (e.g. “?” signs) in your database query and the number of parameters given to the query() method.

For instance, if your query is “SELECT * FROM people WHERE honesty>3″, but you mistakenly call it like this:

$dbh-> query( "SELECT * FROM people WHERE honesty>3", $threshold );

Where you probably meant:

$dbh-> query( "SELECT * FROM people WHERE honesty>?", $threshold );

I think this is reported by the DB_Common class (since a certain version).

On the topic:

Advertisement

3 Responses to “DB Error: mismatch (in a PHP script)”

  1. PhpCatalog Says:

    got the same problem…

  2. Matt Says:

    Thanks! Saved me some time.

  3. sebastian Says:

    Thx for pointing this out!
    Saved me some time, either :)


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.