|
From: Justin To on 1 Jul 2008 17:42 k = "50" my = Mysql::new("localhost", "root", "pass", "table") my.query("INSERT INTO table VALUES('2008-05', #{k}, 324)") /Class.rb:212:in `query': Unknown column '50' in 'field list' (Mysql::Error) How do I insert a variable into a row? Thanks -- Posted via http://www.ruby-forum.com/.
From: ben baka on 2 Jul 2008 07:21 [Note: parts of this message were removed to make it a legal post.] Well, i solved this by bringing ( ' ' ) around the #{k}. Thus your code is likely to become like this, my = Mysql::new("localhost", "root", "pass", "table") my.query("INSERT INTO table VALUES('2008-05', '#{k}', 324)") Hope it solves it. On 7/1/08, Justin To <tekmc(a)hotmail.com> wrote: > > k = "50" > > my = Mysql::new("localhost", "root", "pass", "table") > my.query("INSERT INTO table VALUES('2008-05', #{k}, 324)") > > ./Class.rb:212:in `query': Unknown column '50' in 'field list' > (Mysql::Error) > > How do I insert a variable into a row? > > Thanks > -- > Posted via http://www.ruby-forum.com/. > > -- --Ben Baka Blog : http://benjaminbaka.wordpress.com/
|
Pages: 1 Prev: workarounds for ruby 1.8.6 segmentations faults Next: Mac OS X 10.5.4 - no new Ruby? |