Forum: Ruby passing html params in Ruby

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
199b6c213f0ac380d3f794028bbbb286?d=identicon&s=25 joep (Guest)
on 2007-02-09 19:21
(Received via mailing list)
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.
This topic is locked and can not be replied to.