in reply to Re: CGI/DBI and placeholders, revisited.
in thread CGI/DBI and placeholders, revisited.

You've got to remember that the ';' is not part of the SQL syntax. It's interpreted by the command line tool that you use to access MySQL (or Oracle, or Sybase...) as a statement separator.

Michael

  • Comment on Re: Re: CGI/DBI and placeholders, revisited.

Replies are listed 'Best First'.
Re: Re: Re: CGI/DBI and placeholders, revisited.
by mephit (Scribe) on May 05, 2002 at 04:10 UTC
    OK, well, if this is the case, and neither do() nor prepare() will work if given a string with a semicolon (as if someone had tried to insert a second statement in the form), then why all the hubbub about using placeholders and worrying about someone trying to execute extra commands? Or am I missing something? (I probably am.) Can somebody point me to an explanation somewhere? Thanks.
      OK, well, if this is the case, and neither do() nor prepare() will work if given a string with a semicolon (as if someone had tried to insert a second statement in the form), then why all the hubbub about using placeholders and worrying about someone trying to execute extra commands?

      The behavior is database dependent. Though there appears to not be a problem with MySQL, the advice to not construct queries from un-detainted pieces is still sound. Scripts written with one database in mind tend to migrate to other platforms, or are used as templates for new scripts. It's better to "get things right" even if there's no direct risk on the current platform mix.

        Thank you muchly. I tend to have the mindset, "Well, if it works on my system, it'll work on anybody's." (Bad programmer-wannabe! No treat for you!) *ahem* Anyway, lesson learned, so I'll shut up about this now. Thanks again.
A reply falls below the community's threshold of quality. You may see it by logging in.