passing html params in Ruby

Discussion in 'Ruby' started by joep, Feb 9, 2007.

  1. joep

    joep Guest

    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.
     
    joep, Feb 9, 2007
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. bogdan
    Replies:
    0
    Views:
    417
    bogdan
    Apr 10, 2008
  2. Niv (KP)

    LFSR calcs, passing params.

    Niv (KP), May 13, 2009, in forum: C Programming
    Replies:
    3
    Views:
    616
    Barry Schwarz
    May 16, 2009
  3. Paul Vudmaska

    passing multi params

    Paul Vudmaska, Apr 21, 2004, in forum: Ruby
    Replies:
    2
    Views:
    114
    Mark Sparshatt
    Apr 21, 2004
  4. Barry
    Replies:
    9
    Views:
    485
    Ara.T.Howard
    Sep 15, 2005
  5. Holger Butschek

    passing params to html-form

    Holger Butschek, Sep 8, 2004, in forum: Javascript
    Replies:
    1
    Views:
    115
    Thomas 'PointedEars' Lahn
    Sep 11, 2004
Loading...

Share This Page