Just a troubleshooting tip:
When a query works through phpMyadmin or the mysql client but not through DBI, you should check and see what your code is sending to mysql.
in the [mysqld] section of my.cnf, add
log = query_log
and a plaintext log of connections and sql queries will be logged. (don't enable the query_log on production servers.)