Re: when I insert table, value is a string contains apostrophe - it throws an error there - how to fix
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
- Subject: Re: when I insert table, value is a string contains apostrophe - it throws an error there - how to fix
- From: Vasanta <vtanna1@...>
- Date: Wed, 3 Feb 2010 13:26:17 -0500
Florian:
I am getting this error after I added, this is pointing to dfunction db.escape, I added function below, also I kept modifed code, appreciated fro any help
db.lua:38 attempt to call method 'escape' (a nil value)
--************* Requires *************
require "luasql.sqlite3"
--************* Initial Code *************
--package db
db = {}
--create environment object
local _DB_env = luasql.sqlite3()
local _DB_con = nil
--************* Functions *************
--Connect to the given DB.
function db.connect (dbname)
_DB_con = _DB_env:connect(dbname)
end
--escape to the given DB.
function db.escape (str)
return _DB_con:escape(str)
end
if (v ~= "_ROWID_") then
insertPart = insertPart .. "\'" .. db.escape(v) .. "\', "
-- if post contained field already
if notFullKey and util.tableKeyExists(tableInput, v) then
valuesPart = valuesPart .. "\'" .. _DB_con:escape(tableInput[v]) .. "\', "
elseif util.tableKeyExists(tableInput, tablename .. "." .. db.escape(v)) then valuesPart = valuesPart .. "\'" .. tableInput[tablename .. "." .. db.escape(v)] .. "\', "
-- else if default exists, use it
elseif defaults[tablename .. "." .. db.escape(v)] then valuesPart = valuesPart .. "\'" .. defaults[tablename .. "." .. db.escape(v)] .. "\', "
-- else use empty string
else
valuesPart = valuesPart .. "NULL, "
end
end
On Wed, Feb 3, 2010 at 12:35 PM, Florian Weimer
<fw@deneb.enyo.de> wrote:
* Vasanta:
> Thanks a lot, appreciated, let me add this, also let me delete "|", it
> should look like "conn:escape(v)," instead "v" right?.
Yes, or db.escape(v), once you've added that function.
- References:
- when I insert table, value is a string contains apostrophe - it throws an error there - how to fix, Vasanta
- Re: when I insert table, value is a string contains apostrophe - it throws an error there - how to fix, Florian Weimer
- Re: when I insert table, value is a string contains apostrophe - it throws an error there - how to fix, Vasanta
- Re: when I insert table, value is a string contains apostrophe - it throws an error there - how to fix, Florian Weimer
- Re: when I insert table, value is a string contains apostrophe - it throws an error there - how to fix, Vasanta
- Re: when I insert table, value is a string contains apostrophe - it throws an error there - how to fix, Florian Weimer
- Re: when I insert table, value is a string contains apostrophe - it throws an error there - how to fix, Vasanta
- Re: when I insert table, value is a string contains apostrophe - it throws an error there - how to fix, Florian Weimer
- Re: when I insert table, value is a string contains apostrophe - it throws an error there - how to fix, Vasanta
- Re: when I insert table, value is a string contains apostrophe - it throws an error there - how to fix, Florian Weimer