On Sat, Aug 30, 2003 at 04:05:18PM +0900, Meino Christian Cramer wrote:
> > >  Generally: how can I process input to escape "special" characters
> > 
> > Regexp.escape(aString)

No, that's the wrong escaper. If you're sending SQL, then you need to use
SQL escaping rules, not Regexp escaping rules.

> Unfortunately the "'" is not escaped and this character is that,
> what make my headache...
> 
> I have a broadcaster called "N'Djamena".
> 
> The "'" in its name confuses the string sent to mySQL...

Indeed.

> By the way: I tried DBI but it seems not 1.8.0-ready ? I got a lot
> of errors...

It works just fine for me. I get a couple of warnings only, no errors. I use
DBI-0.0.20 with mysql, OCI8, sqlite

> Now I am using ruby-mysql-0.2.1.tar.gz, which works fine...
> beside my "special-char" problems.

Ah, OK. I think this is the 'pure ruby' solution which talks the Mysql
protocol directly over the wire.

I use mysql-ruby-2.4.4, which wraps the C API. Probably this is what DBI
expects, which would explain why it doesn't work for you.

mysql-ruby contains a class method:  Mysql.escape_string (alias Mysql.quote)
which does exactly what you want.

Have you checked the documentation for ruby-mysql to see if it has such a
function? If not, maybe you should change.

Regards,

Brian.