Server Error: Never seen this error before when editing in admin area.

Cupara

Well-known member
Error: mysqli_stmt::bind_param() [mysqli-stmt.bind-param]: Number of variables doesn't match number of parameters in prepared statement

xPortal.php line 101:
PHP:
        if ($dwInput['temp_id'])

            $dw->setExistingData($dwInput['temp_id']);
if line is line 100.

Blocks.php line 40:
PHP:
                ', $temp_id);

Entire statement including line 40:
PHP:
        $blockById = $this->_getDb()->fetchRow('
            SELECT temp_id, temp_title, temp_template, temp_active, temp_position, temp_order
                FROM xportal_blocks
                WHERE temp_id = ?
                ', $temp_id);

Block.php line 29:
PHP:
        return array('xportal_block' => $this->getModelFromCache('xPortal_Model_Blocks')->getBlockId($tempid));

Entire statement including line 29:
PHP:
    protected function _getExistingData($data)
    {
        if (!$tempid = $this->_getExistingPrimaryKey($data, 'temp_id'))
        {
            return false;
        }
        if (!$tempid = $this->getModelFromCache('xPortal_Model_Blocks')->getBlockId($tempid))
        {
            return false;
        }
        return array('xportal_block' => $this->getModelFromCache('xPortal_Model_Blocks')->getBlockId($tempid));
    }

I have altered, played, and even removed code in an attempt to fix this error. I have read and re-read threads and code from various XenForo files with no resolution in sight.

Any help would be much appreciated.
 
The queries that you've included look ok. Can you show the entire backtrace of the error?
 
And what's the complete error message?
I don't think that anybody can help you without;)

Oh, too slow
 
Here it is as requested:
Server Error

mysqli_stmt::bind_param() [mysqli-stmt.bind-param]: Number of variables doesn't match number of parameters in prepared statement
  1. XenForo_Application::handlePhpError()
  2. mysqli_stmt->bind_param()
  3. call_user_func_array() in Zend/Db/Statement/Mysqli.php at line 204
  4. Zend_Db_Statement_Mysqli->_execute() in Zend/Db/Statement.php at line 317
  5. Zend_Db_Statement->execute() in Zend/Db/Adapter/Abstract.php at line 479
  6. Zend_Db_Adapter_Abstract->query() in Zend/Db/Adapter/Abstract.php at line 753
  7. Zend_Db_Adapter_Abstract->fetchRow() in xPortal/Model/Blocks.php at line 40
  8. xPortal_Model_Blocks->getBlockId() in xPortal/DataWriter/Block.php at line 29
  9. xPortal_DataWriter_Block->_getExistingData() in XenForo/DataWriter.php at line 505
  10. XenForo_DataWriter->setExistingData() in xPortal/ControllerAdmin/xPortal.php at line 99
  11. xPortal_ControllerAdmin_xPortal->actionSaveBlock() in XenForo/FrontController.php at line 310
  12. XenForo_FrontController->dispatch() in XenForo/FrontController.php at line 132
  13. XenForo_FrontController->run() in /home/xen/public_html/admin.php at line 13
 
time to start debugging;)

check here
return array('xportal_block' => $this->getModelFromCache('xPortal_Model_Blocks')->getBlockId($tempid));

if $tempid is set and have a valid value
2. check if in
$blockById = $this->_getDb()->fetchRow('
SELECT temp_id, temp_title, temp_template, temp_active, temp_position, temp_order
FROM xportal_blocks
WHERE temp_id = ?
', $temp_id);

$temp_id exists and have a valid value..

the best way is to use an real debugger and to trace it on runtime
my 0.02$:)
 
*confused* I am now confused Ragtek. I'm not sure exactly what I should be looking for or even doing to debug this problem.
 
I THINK THAT YOU DON'T HAVE A VALUE IN YOUR QUERY;
so fastest way to check this:
search:

return array('xportal_block' => $this->getModelFromCache('xPortal_Model_Blocks')->getBlockId($tempid));

replace with
die('tempid: ' . $tempid);
return array('xportal_block' => $this->getModelFromCache('xPortal_Model_Blocks')->getBlockId($tempid));

save and run the script

search
$blockById = $this->_getDb()->fetchRow('
SELECT temp_id, temp_title, temp_template, temp_active, temp_position, temp_order
FROM xportal_blocks
WHERE temp_id = ?
', $temp_id);

replace with:

die('$temp_id: ' . $temp_id);
$blockById = $this->_getDb()->fetchRow('
SELECT temp_id, temp_title, temp_template, temp_active, temp_position, temp_order
FROM xportal_blocks
WHERE temp_id = ?
', $temp_id);

professional way for this:
use loggers/ or use your IDE and the debugger, set the breakpoints/loggers and run the script:D
 
Well, it doesn't have to be a "valid" value - but it can't be an array...
 
I'm not even sure how its even passing as an array when I'm trying to pass values only. This whole thing has me confused. LOL
 
Code:
        if (!$tempid = $this->getModelFromCache('xPortal_Model_Blocks')->getBlockId($tempid))
        {
            return false;
        }
        return array('xportal_block' => $this->getModelFromCache('xPortal_Model_Blocks')->getBlockId($tempid));

You turned $tempid into an array on the first line.
 
I remove that then I get this error:
Server Error

_getExistingData returned an array but did not include data for the primary table
  1. XenForo_DataWriter->setExistingData() in xPortal/ControllerAdmin/xPortal.php at line 99
  2. xPortal_ControllerAdmin_xPortal->actionSaveBlock() in XenForo/FrontController.php at line 310
  3. XenForo_FrontController->dispatch() in XenForo/FrontController.php at line 132
  4. XenForo_FrontController->run() in /home/xen/public_html/admin.php at line 13
 
Here it is:
PHP:
<?php

class xPortal_DataWriter_Block extends XenForo_DataWriter
{
    protected function _getFields()
    {
        return array(
            'xportal_blocks' => array(
                'temp_id' => array('type' => self::TYPE_UINT, 'autoIncrement' => true),
                'temp_title' => array('type' => self::TYPE_STRING),
                'temp_template' => array('type' => self::TYPE_STRING),
                'temp_active' => array('type' => self::TYPE_BOOLEAN, 'default' => 1),
                'temp_position' => array('type' => self::TYPE_BOOLEAN, 'default' => 2),
                'temp_order' => array('type' => self::TYPE_UINT, 'default' => 1),
            )
        );
    }

    protected function _getExistingData($data)
    {
        if (!$tempid = $this->_getExistingPrimaryKey($data, 'temp_id'))
        {
            return false;
        }
        return array('xportal_block' => $this->getModelFromCache('xPortal_Model_Blocks')->getBlockId($tempid));
    }

    protected function _getUpdateCondition($tableName)
    {
        return 'temp_id = ' . $this->_db->quote($this->getExisting('temp_id'));
    }

    protected function _postDelete()
    {

        $model = $this->getModelFromCache('xPortal_Model_Blocks');

        $deletedId = $this->_existingData['xportal_block']['temp_id'];
        if ($model->hasData($deletedId))
        {
            $dw->delete();
        }
    }
}
 
hm, first problem in your code: you're using different indexes/table names
'xportal_blocks' => array(
'xportal_block'

the second should also be xportal_blocks
 
2. problem
PHP:
    protected function _postDelete()
    {

        $model = $this->getModelFromCache('xPortal_Model_Blocks');

        $deletedId = $this->_existingData['xportal_block']['temp_id'];
        if ($model->hasData($deletedId))
        {
            $dw->delete();
        }
    }
there's no $dw in the scope;)
 
Top Bottom