Fatal Error building block.

Permalink 1 user found helpful
I am trying to create a custom slide show advanced block that added a title and description field to the slideshow but I cant figure out this fatal error... any help would be appreciated.

//loop through and add the images
         $pos=0;
         foreach($data['imgFIDs'] as $imgFID){ 
            if(intval($imgFID)==0 || $data['fileNames'][$pos]=='tempFilename') continue;
            $vals = array(intval($this->bID),intval($imgFID), trim($data['url'][$pos]),  trim($data['title'][$pos]), trim($data['description'][$pos]), intval($data['duration'][$pos]),intval($data['fadeDuration'][$pos]),
                  intval($data['groupSet'][$pos]),intval($data['imgHeight'][$pos]),$pos);
            $this->db->query("INSERT INTO btSlideshowImgAdvanced (bID,fID,url,title,description,duration,fadeDuration,groupSet,imgHeight,position) values (?,?,?,?,?,?,?,?)",$vals);
            $pos++;
         }
      }



Fatal error: Uncaught exception 'ADODB_Exception' with message 'mysql error: [1136: Column count doesn't match value count at row 1] in EXECUTE("INSERT INTO btSlideshowImgAdvanced (bID,fID,url,title,description,duration,fadeDuration,groupSet,imgHeight,position) values (125,8,'','Test 2','Test 1.2',5,2,0)") ' in /var/www/vhosts/demo.idealer1.com/httpdocs/concrete5.3.1.1/concrete/libraries/3rdparty/adodb/adodb-exceptions.inc.php:78 Stack trace: #0 /var/www/vhosts/demo.idealer1.com/httpdocs/concrete5.3.1.1/concrete/libraries/3rdparty/adodb/adodb.inc.php(1042): adodb_throw('mysql', 'EXECUTE', 1136, 'Column count do...', 'INSERT INTO btS...', false, Object(ADODB_mysql)) #1 /var/www/vhosts/demo.idealer1.com/httpdocs/concrete5.3.1.1/concrete/libraries/3rdparty/adodb/adodb.inc.php(998): ADOConnection->_Execute('INSERT INTO btS...') #2 /var/www/vhosts/demo.idealer1.com/httpdocs/concrete5.3.1.1/concrete/libraries/3rdparty/adodb/adodb.inc.php(766): ADOConnection->Execute('INSERT INTO btS...', Array) #3 [internal function]: ADOConnec in /var/www/vhosts/demo.idealer1.com/httpdocs/concrete5.3.1.1/concrete/libraries/3rdparty/adodb/adodb-exceptions.inc.php on line 78

 
aaron replied on at Permalink Reply
bump
Tony replied on at Permalink Reply
Tony
within your database query, you need to have the same number of question marks, as array elements, as columns:

$vals = array(
intval($this->bID), 
intval($imgFID), 
trim($data['url'][$pos]),  trim($data['title'][$pos]), trim($data['description'][$pos]), intval($data['duration'][$pos]),
intval($data['fadeDuration'][$pos]),
intval($data['groupSet'][$pos]),
intval($data['imgHeight'][$pos]),
$pos);
$this->db->query("INSERT INTO btSlideshowImgAdvanced (bID,fID,url,title,description,duration,fadeDuration,groupSet,imgHeight,position) values (?,?,?,?,?,?,?,?,?,?)",$vals);
aaron replied on at Permalink Reply
Thanks, that worked