Thanks Sarah and Andre!

I figured out the % wildcard for SQL but I like Sarah's irev strategy too. I'm attempting to modify what Sarah describes to include a search field on card and a WHERE in the SQL. Having a hard time getting my head around sending the POST to the irev script so that I can search by field in SQL and then returning the data to the stack.

Here's where I'm at:

--On the card-
on mouseUp
put cd fld "SearchName" into tTeacher
libUrlFormData("name", tTeacher)
post it to url "http://jpatten.on-rev.com/readDB.irev";
put "http://jpatten.on-rev.com/readDB.irev"; into tData
put tData into fld "tempdata"
...

--in the irev file
put $_POST["name"] into tTeacher
( and then everything that Sarah describes below)

My confusion comes from trying to submit two actions to the irev file, a POST of the card field text and the Open&Query of the database. What is the proper way to get the text (POST) included as a WHERE in the irev SQL action?

Hope that made sense.

Thank you!

John Patten


-----------------snip---------------------
Message: 17
Date: Fri, 26 Mar 2010 09:56:57 +1000
From: Sarah Reichelt <sarah.reich...@gmail.com>
Subject: Re: Connecting Rev stack to On-Rev mySQL DB?
To: How to use Revolution <use-revolution@lists.runrev.com>
Message-ID:
        <f99b52861003251656m7537ea7fvf9ffca2a35a2b...@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1



John, it looks like you are trying to access the database from outside
the server.
By default this is not permitted. There is a way to set up access from
outside, but I don;t remember what it is. Search the list archives as
I think it was discussed a few weeks ago.

The more regular way of connecting is via an irev script file on your
on-rev server.
Here is how I do it:

put this script into an irev file, replace all the *******'s with your
own variables, and upload it to your on-rev site.

<?rev
        put "*********" into tDBname
        put "*********" into tDBuser
        put "*********" into tDBpass

        put revOpenDatabase("mysql", "localhost", tDBname, tDBuser, tDBpass)
into tDBconnection
        if tDBconnection is not a number then put "Error: could not connect
to database!"

        if tDBconnection is a number then
                -- query the database, then close it
                put "********" into tTableName
                put "SELECT * FROM " & tTableName into tSQL
                        
                put revDataFromQuery(tab, cr, tDBconnection, tSQL) into tData
                revCloseDatabase tDBconnection

                put tData
        end if
?>

In your Rev stack, use this script (assuming the irev script file is
called "readDB.irev"):

on mouseUp
  put "http://myusername.on-rev.com/readDB.irev"; into tDBdata
  -- now display it
end mouseUp


For further refinements, edit the irev script to take a GET or POST
parameter and apply that in the SELECT statement.

Cheers,
Sarah
_______________________________________________
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution

Reply via email to