Accessing mySQL DB from stack utilizing revserver/irev/on-rev?

Sarah Reichelt sarah.reichelt at gmail.com
Sat Jul 23 04:42:28 EDT 2011


Hi John,

When POSTing variables to the server, you have to identify them, so
the script on the server can tell what is what.
So your call to the server would need to be something like this:

put URLEncode(fld "username") into tUserName
put URLEncode(fld "password") into tPassword
put "username=" & tUserName & "&password=" & tPassword into tLoginVariables
post tLoginVariables to URL ("http://server.on-rev.com/sandbox/login.irev")

Now when this gets to your login.irev file on the server, it can read
the contents of the $_POST array to find what it needs:

<?irev

put $_POST["username"] into tUserName
put $_POST["password"] into tPassword
...

Now connect to the database exactly as you would on your desktop, but
use localhost as the database address, since the database is on the
same server as the irev file.

Note that you will need to have used your cPanel to create the database first.

Hope this helps, but contact me off-list if you would like me to send
you some sample scripts.

Cheers,
Sarah
(using Lion and loving it)


On Sat, Jul 23, 2011 at 6:34 AM, John Patten <johnpatten at mac.com> wrote:
> Hi All
>
>  I'm trying to get a handle on using on-rev and irev files on the server in
> combination with post commands and mysql queries directly from within a
> stack.
>
>  Here's what I have so far:
>
>  1. One card with two fields (username & password) and a button.
>
>  2. mySQL table with records consisting of a field for username and a field
> for password.
>
>  3. the beginning of an irev file in directory on on-rev server.
>
>
>
> My button contains the following script:
>
> on mouseup
>
> put URLEncode(cd fld "username")& URLEncode(cd fld "password") into
> tLoginVariables
>
> post tLoginVariables to URL ("http://server.on-rev.com/sandbox/login.irev")
>
> end mouseUp
>
>
>
> irev file on the on-rev server:
>
>
>
> <?irev
>
> put "address-of-db" into tDatabaseAddress
>
>  put "dbname" into tDatabaseName
>
>  put "dbUsername" into tDatabaseUser
>
>  put "dbpassword" into tDatabasePassword
>
>
>
>  ...and that's about as far as I've gotten so far.  :-(
>
>
>
> Essentially I want to create the functionality I have working in my stack
> now into a project that makes the database calls via an irev (on-rev) calls.
> I would like to try making a mobile app out of what I have but my stack
> relies heavily on calls to the mySQL database for data.
>
>  I have very limited experience with irev and just need to know how to query
> the database, get the resulting data from the query, do some stuff with in
> the stack, and then put the data back into the database.
>
>  Is there and example of this available?
>
>  Thank you!
>
> John Patten
>
> SUSD




More information about the use-livecode mailing list