Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 541513
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T10:21:03+00:00 2026-05-13T10:21:03+00:00

I’ve got the following Perl code which makes a DBI call: my $artsql =

  • 0

I’ve got the following Perl code which makes a DBI call:

my $artsql = q{ *** SNIP A BUNCH OF SQL ***
                where a.article_id != ?
                      and at.type_name != 'List Element'   -- don't get list children
                      and aw.flowstate = 'Published'
                      and a.visible_as_article = 1 }
      . ( $filter ? q{and ch.channel_id = ?
                      and cat.category_id = ? }
                  : '' ) 
         . q{order by a.publish_date desc
                limit 5};

my @bind = ( $article );
push @bind, ( $channel_id, $category_id ) if $filter;

my $articles = $dbh->selectall_arrayref( $artsql, { Slice => { } }, @bind );

When $filter is on, this code was dying with the error:

DBD::mysql::db selectall_arrayref failed: called with 3 bind variables when 1 are needed

At first I thought this was a problem with the ternary conditional in the middle of the string, (I’ve been bitten by that bug multiple times) but it was correct. Dumping some debug values shows that the query and @bind array were being constructed correctly.

I then noticed that the query had a SQL comment right after the first bind variable, so on a whim I removed it. Poof, it worked!

According to the MySQL docs on comments,

MySQL Server supports three comment styles:
From a “#” character to the end of the line.
From a “– ” sequence to the end of the line. In MySQL, the “– ” (double-dash) comment > style requires the second dash to be followed by at least one whitespace or control
character (such as a space, tab, newline, and so on).

Since the comment had -- followed by a space and (presumably) ended with the end of the line, why did MySQL choke? Is DBI doing something weird with newlines or whitespace behind the scenes?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T10:21:04+00:00Added an answer on May 13, 2026 at 10:21 am

    There doesn’t look to be anything wrong with your SQL or Perl code.

    This could be a bug in DBI, DBD::mysql or MySQL itself. The first step in debugging this problem would be to find out which bit is at fault. So, start by eliminating the variables.

    Start by eliminating the bind variables, hard code some values and see if the process correctly. If not then its probably a bug in DBD::mysql or DBI. First try updating both of them and see if the problem is fixed. If that doesn’t work, report the bug. Note there’s a similar comment parsing bug so it very may well be DBD::mysql. (You’re sure it’s do not get list children and not don't get list children?)

    Next eliminate Perl from the equation. Run the query in the mysql shell (use \e to bring up an editor). Does it have the same problem? If so, then MySQL is at fault. Again, try upgrading.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i got an object with contents of html markup in it, for example: string
I've got a string that has curly quotes in it. I'd like to replace
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a bunch of posts stored in text files formatted in yaml/textile (from
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I am trying to loop through a bunch of documents I have to put
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I have a JSP page retrieving data and when single or double quotes are

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.