From: Dossy Date: 2002-05-19T21:17:09+09:00 Subject: Re: passing CGI parameters to ruby MySQL interface On 2002.05.19, sentinel wrote: > Hi, > > I'm spending a lot of time trying to pass cgi.parameters to a MySQL > database > via the ruby MySQL module. > > For instance, using > > $my.query("insert into agent(_case, name1, name2) values > (cgi.params['_case'], cgi.params['name1'], cgi.params['name2'])") > > it will write to the database, but the values will be literally what > is shown - i.e. cgi.params['name2'], etc. > > I'm probably missing something obvious, but how can I insert the hash > values into the INSERT values ? $my.query("insert into agent(_case, name1, name2) values (" + cgi.params['_case'] + ", " + cgi.params['name1'] + ", " + cgi.params['name2']) ) Or, maybe more elegantly: $my.query(sprintf "insert into agent(_case, name1, name2) values (%s, %s, %s)", cgi.params['_case'], cgi.params['name1'], cgi.params['name2'] ) You may have to escape the %s with single-quotes if they're going to be string values, i.e.: '%s' However, I don't even think this will do what you want, but you didn't describe the problem you're trying to solve in sufficient detail, but I hope this helps ... -- Dossy -- Dossy Shiobara mail: dossy@panoptic.com Panoptic Computer Network web: http://www.panoptic.com/ "He realized the fastest way to change is to laugh at your own folly -- then you can let go and quickly move on." (p. 70)