Hello Guys, I working on a xenforo addon, And I'm using this code to get data from data base $db = $this->_getDb(); $Countries = array('US', 'UK'); $query = "SELECT id FROM cities WHERE country IN (?) LIMIT $start, $limit"; return $db->fetchCol($query, $Countries); PHP: But Output mysqli_stmt::bind_param(): Number of variables doesn't match number of parameters in prepared statement Code (markup): If I remove UK Or US from array, Then it works, please resolve my code to collect data from various countries
Can you post the DB class, we can't really tell you what we can't see. That method isn't a PHP one, seems like a custom modal. I know Zend has it but I think it is different on this system.
It's because you're posting an array with multiple values to one (?) parameter. That's not how it works. What you need to do is join the array, or if you always know how many elements you have, make it a string variable - something like: $countries = "US, UK" (as far as I remember, IN() checks a comma-separated list for values in the chosen columns.
The instatement must be build by yourselve, pdo doesn't replace the ? with the given array as it only wants to put a string there. http://stackoverflow.com/questions/920353/can-i-bind-an-array-to-an-in-condition and more questions about this issue.