18.06.2024, 11:45
Hi everyone,
I have problemas adding a string variable into a query.
This works fine;
---------------------------------------------------------------------------------------------------------
require('luasql.mysql')
require('json')
http = require('socket.http')
env = luasql.mysql()
dbcon, err = env:connect('knx', 'root','123123', '192.168.6.19', '3306')
log(dbcon, err)
dbcon:execute('INSERT INTO test (name, value) VALUES ("Name1", "11")')
dbcon:execute('INSERT INTO test (name, value) VALUES ("Name2", "22")')
---------------------------------------------------------------------------------------------------------
but i'm struggling with no success when I try to add both fields as local variables, for example
---------------------------------------------------------------------------------------------------------
require('luasql.mysql')
require('json')
http = require('socket.http')
env = luasql.mysql()
dbcon, err = env:connect('knx', 'root','123123', '192.168.6.19', '3306')
log(dbcon, err)
local nameparam = 'NameX'
local valueparam = 1000
¿¿¿???????
---------------------------------------------------------------------------------------------------------
I can't find the right string parametrization or contatenarion to create the right query
something is tricking me with the ' and " that I cant solve
Any help is wellcome!!
Thanks!!
Kike
I have problemas adding a string variable into a query.
This works fine;
---------------------------------------------------------------------------------------------------------
require('luasql.mysql')
require('json')
http = require('socket.http')
env = luasql.mysql()
dbcon, err = env:connect('knx', 'root','123123', '192.168.6.19', '3306')
log(dbcon, err)
dbcon:execute('INSERT INTO test (name, value) VALUES ("Name1", "11")')
dbcon:execute('INSERT INTO test (name, value) VALUES ("Name2", "22")')
---------------------------------------------------------------------------------------------------------
but i'm struggling with no success when I try to add both fields as local variables, for example
---------------------------------------------------------------------------------------------------------
require('luasql.mysql')
require('json')
http = require('socket.http')
env = luasql.mysql()
dbcon, err = env:connect('knx', 'root','123123', '192.168.6.19', '3306')
log(dbcon, err)
local nameparam = 'NameX'
local valueparam = 1000
¿¿¿???????
---------------------------------------------------------------------------------------------------------
I can't find the right string parametrization or contatenarion to create the right query
something is tricking me with the ' and " that I cant solve
Any help is wellcome!!
Thanks!!
Kike