# Passing html params in Ruby

**URL:** <https://www.ruby-forum.com/t/passing-html-params-in-ruby/85067>\
**Category:** Ruby\
**Created:** [February 9, 2007, 7:21pm UTC](https://www.ruby-forum.com/t/passing-html-params-in-ruby/85067 "2007-02-09T19:21:13Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![joep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/87869e/32.png) [@joep](https://www.ruby-forum.com/u/joep)\
**Post date:** [February 9, 2007, 7:21pm UTC](https://www.ruby-forum.com/t/passing-html-params-in-ruby/85067/1 "2007-02-09T19:21:13Z")

</div>

I have an AJAX page that I built.  
The user enters in some info.  
I format a query string and want use it to query my DB.

something like this:

var query\_string = "SELECT \* FROM mydbtable;

\<%  
require ‘dbi’  
require ‘cgi’  
cgi = CGI.new  
params = cgi.params

new\_query\_string = cgi.params[‘query\_string’]

dbh =  
DBI.connect(“dbi:Pg:dbname=blank;host=blank;port=blank”,“blank”,“blank”)

newsth = dbh.execute("#{new\_query\_string}")

rows = newsth.fetch\_all

%\>

the query\_string variable is not passed in the ‘params’, so obviously  
this code is never going to work.  
How do I pass the formatted variable (query\_string) into my embedded  
ruby code so that I can query my DB?

Thank you in advance.
