in reply to random bind_col error using DBI

It means that your $query sometimes only has a single placeholder ('?') in it. So I'd concentrate on how you set up the $query at this point in debugging this application.

Replies are listed 'Best First'.
Re^2: random bind_col error using DBI
by chauzer (Novice) on May 23, 2005 at 18:13 UTC
    Can you explain what you mean by a query having only a single placeholder? I'm kind of confused by that when debugging, i have it print out the actual query as well so i can see which query caused the error... an example of one query that caused the bind_col error was this: SELECT user_id, username FROM users WHERE purch_perm_id != 1 AND deleted != 1 ORDER BY username the weird thing is, if i hit refresh, the page will load fine and there won't be any errors

      I didn't say "query", I said "$query" - as in the variable you're passing in to $dbh->prepare().

      The query you posted, "SELECT user_id, username FROM users WHERE purch_perm_id != 1 AND deleted != 1 ORDER BY username" has no placeholders, so you shouldn't be binding anything.

      Then the next place to look is where you're doing your binding.

      @dsetcols=[];
      I don't think this is doing what you think it's doing. It might be, I'm not entirely sure. This is setting @dsetcols to be an array with one element: an arrayref. You probably want:
      @dsetcols=();
      which sets @dsetcols to an empty array. Next you do:
      @fieldnames = split(/,/, $fnames);
      So, when your code fails, what is $fnames? Print that out in your error message, too. I would expect that your example query doesn't have a blank $fnames, even though it should.