1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

fetchCol Prob

Discussion in 'PHP' started by vOlLvEriNe, Aug 9, 2015.

  1. #1
    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
     
    vOlLvEriNe, Aug 9, 2015 IP
  2. ThePHPMaster

    ThePHPMaster Well-Known Member

    Messages:
    737
    Likes Received:
    52
    Best Answers:
    33
    Trophy Points:
    150
    #2
    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.
     
    ThePHPMaster, Aug 9, 2015 IP
  3. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #3
    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.
     
    PoPSiCLe, Aug 10, 2015 IP
  4. EricBruggema

    EricBruggema Well-Known Member

    Messages:
    1,740
    Likes Received:
    28
    Best Answers:
    13
    Trophy Points:
    175
    #4
    EricBruggema, Aug 13, 2015 IP
  5. vOlLvEriNe

    vOlLvEriNe Member

    Messages:
    99
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #5
    Its XF's Custom function
     
    vOlLvEriNe, Aug 15, 2015 IP
  6. vOlLvEriNe

    vOlLvEriNe Member

    Messages:
    99
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #6
    Thanks for replies, solved!
     
    vOlLvEriNe, Aug 15, 2015 IP