[MySQL] Mixed named and positional parameters

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
nutkenz
Forum Contributor
Posts: 155
Joined: Tue Jul 19, 2005 12:25 pm

[MySQL] Mixed named and positional parameters

Post by nutkenz »

QUERY:

Code: Select all

SELECT * FROM feed_products WHERE feed_id=21 AND name='L\'Oblique AZO verticale hangmap gekleurd'
 
Raw version (notice that the quote is escaped, which is why it's blue in the code view above): SELECT * FROM feed_products WHERE feed_id=21 AND name='L\'Oblique AZO verticale hangmap gekleurd'

ERROR:

SQLSTATE[HY093]: Invalid parameter number: mixed named and positional parameters

What does this mean? I couldn't find a decent explanation anywhere
Last edited by nutkenz on Sat Jun 14, 2008 4:16 am, edited 3 times in total.
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: [MySQL] Mixed named and positional parameters

Post by Benjamin »

Your not escaping the data with mysql_real_escape_string.

They query below should work because there is a \ in front of the '.

Code: Select all

 
SELECT * FROM feed_products WHERE feed_id=21 AND name='L\'Oblique AZO verticale hangmap gekleurd'
 
EDIT, which doesn't show up in code view:
SELECT * FROM feed_products WHERE feed_id=21 AND name='L\'Oblique AZO verticale hangmap gekleurd'
nutkenz
Forum Contributor
Posts: 155
Joined: Tue Jul 19, 2005 12:25 pm

Re: [MySQL] Mixed named and positional parameters

Post by nutkenz »

You're right, it doesn't show up in code view; the string is already escaped:

SELECT * FROM feed_products WHERE feed_id=21 AND name='L\'Oblique AZO verticale hangmap gekleurd'
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: [MySQL] Mixed named and positional parameters

Post by Benjamin »

Are you calling the query with mysql_query?
nutkenz
Forum Contributor
Posts: 155
Joined: Tue Jul 19, 2005 12:25 pm

Re: [MySQL] Mixed named and positional parameters

Post by nutkenz »

No, I'm using Zend DB with the PDO MySQL adapter
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: [MySQL] Mixed named and positional parameters

Post by Benjamin »

I'm not familiar with that, but I did find a link. Search google using that error code.

http://framework.zend.com/issues/browse/ZF-159
Post Reply