Hi,
Sending this mail again since there appears to have been delivery
trouble last time:
Recently we had some trouble with no parameters bound exception when
querying a database with a title from a news article.
The strange thing is, normally everything works fine even if single
quotes (') or double quotes (") are present in the title. I remember
reading about an issue of question marks causing this problem earlier,
but that was apparently solved, and question marks on their own seem
fine. However, it seems that in the rare case where a title has both a
single quote and a question mark, the error occurs.
This is the error:
*Fatal error*: Uncaught exception 'Zend_Db_Statement_Exception' with
message 'SQLSTATE[HY093]: Invalid parameter number: no parameters were
bound' in
C:\domains\infortellence.eu\wwwroot\forca\library\Zend\Db\Statement\Pdo.php:227
Stack trace: #0
C:\domains\infortellence.eu\wwwroot\forca\library\Zend\Db\Statement.php(279):
Zend_Db_Statement_Pdo->_execute(Array) #1
C:\domains\infortellence.eu\wwwroot\forca\library\Zend\Db\Adapter\Abstract.php(383):
Zend_Db_Statement->execute(Array) #2
C:\domains\infortellence.eu\wwwroot\forca\library\Zend\Db\Adapter\Pdo\Abstract.php(206):
Zend_Db_Adapter_Abstract->query(Object(Zend_Db_Select), Array) #3
C:\domains\infortellence.eu\wwwroot\forca\library\Zend\Db\Table\Abstract.php(1104):
Zend_Db_Adapter_Pdo_Abstract->query(Object(Zend_Db_Select)) #4
C:\domains\infortellence.eu\wwwroot\forca\library\Zend\Db\Table\Abstract.php(1011):
Zend_Db_Table_Abstract->_fetch('title = 'Tussen...', NULL, 1) #5
C:\domains\infortellence.eu\wwwroot\forca\application\controllers\NewsFeedController.php(410):
Zend_ in
*C:\domains\infortellence.eu\wwwroot\forca\library\Zend\Db\Statement\Pdo.php*
on line *227
*The relevant lines of code are these two:
$sql = $db->quoteInto('title = ?', $title);
$checkTitleExists = $newsItem->fetchRow($sql);
The article that is being retrieved is the following:
http://www.evmi.nl/nieuws/overig/4337/tussendoortje-dsm%27s-paraplumerk-nu-al-lek%3F.html
Which comes from the RSS source: http://www.evmi.nl/rss/feed.xml
I'm using a quite recent ZF snapshot (6493). But it has happened in an
earlier stable release as well.
I've also tried not using quoteInto, or doublequotes in the function,
but it seems to occur regardless.
Best regards,
Pieter.