1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

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

Discussion in 'XenForo Development Discussions' started by Mythotical, Jun 19, 2011.

  1. Mythotical

    Mythotical 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.
     
  2. Mike

    Mike XenForo Developer Staff Member

    The queries that you've included look ok. Can you show the entire backtrace of the error?
     
  3. ragtek

    ragtek Guest

    And what's the complete error message?
    I don't think that anybody can help you without;)

    Oh, too slow
     
  4. Mythotical

    Mythotical Well-Known Member

    Here it is as requested:
     
  5. ragtek

    ragtek Guest

    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$:)
     
  6. Mythotical

    Mythotical Well-Known Member

    *confused* I am now confused Ragtek. I'm not sure exactly what I should be looking for or even doing to debug this problem.
     
  7. ragtek

    ragtek Guest

    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
     
  8. Mythotical

    Mythotical Well-Known Member

    Ok did both, the first returns this:
    The second returns:
    So I know the fetchRow is working but not sure why I would get tempid: Array.
     
  9. Mike

    Mike XenForo Developer Staff Member

    Well, it doesn't have to be a "valid" value - but it can't be an array...
     
  10. Mythotical

    Mythotical Well-Known Member

    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
     
  11. Mike

    Mike XenForo Developer Staff Member

    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.
     
  12. Mythotical

    Mythotical Well-Known Member

    I remove that then I get this error:
     
  13. ragtek

    ragtek Guest

    Post your complete datawriter here...
     
  14. Mythotical

    Mythotical Well-Known Member

    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();
            }
        }
    }
     
  15. ragtek

    ragtek Guest

    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
     
  16. ragtek

    ragtek Guest

    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;)
     
  17. Mythotical

    Mythotical Well-Known Member

    Well poop, didn't even notice that. Ty Ragtek. I'll go fix that stuff and test again.
     
    Vodkaholic likes this.
  18. Wuebit

    Wuebit Well-Known Member

    lol not heard that in ages :ROFLMAO:
     
  19. Mythotical

    Mythotical Well-Known Member

    Lol figured it was better than calling myself other names.
     
    Vodkaholic likes this.

Share This Page