lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]



Hi.

What is the best way to make strings safe when using database and files (saving string to them)? I'm trying to do something like in PHP: http://www.php.net/manual/en/function.addslashes.php

There were some examples in wiki:
http://lua-users.org/wiki/TextProcessing

So I made following function:
function addslashes(s)
  return (string.gsub(s, "([^'])'", "%1\'"))
end

I'm using apostrophes (') when using strings. Unfortunately my function does not seem to work all the time (for example with database queries)... :(

f