From: neil@...9.co.uk (sentinel) Date: 2002-05-20T04:49:14+09:00 Subject: Re: passing CGI parameters to ruby MySQL interface Thank you very much. These suggestions do just what I need - I may tweek them a bit, but as I use JavaScript to do a lot of the validation before anything is sent to the ruby script, I won't need to alter much. Much appreciated. Regards Neil. Patrick Roemer wrote in message news:... > Hi, > > sentinel wrote: > > > $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 ? > > Using DBI it might look like this: > > parms=... # Get params from CGI > dbh=DBI.connect('DBI:Mysql:databasename','username','password') > insh=dbh.prepare('insert into agent(_case,name1,name2) values(?,?,?)') > insh.execute([parms['_case'],parms['name1'],parms['name2']]) > > I wouldn't use cgi.params directly, because I would like to > check whether all params are present (and maybe perform some > more checks and/or conversions, too) and because it contains > Array values, as CGI params may be multi-valued. > > Regards, > Patrick