in reply to Re: random bind_col error using DBI
in thread random bind_col error using DBI

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

Replies are listed 'Best First'.
Re^3: random bind_col error using DBI
by Tanktalus (Canon) on May 24, 2005 at 23:40 UTC

    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.