Connecting Rev stack to On-Rev mySQL DB?

Sarah Reichelt sarah.reichelt at gmail.com
Thu Mar 25 19:56:57 EDT 2010


> My Developer Conference 2009 DVDs arrived yesterday and I listened to Devin
> do his presentations on connecting rev to an on-rev mysql db. He made it
> look so easy, I thought I'd give it a try!
>
>
> My attempts are failing with the error: "Access denied for user
> 'jpatten_elearn'@'216.64.xxx.xx' (using password: YES)"
>
> I'm behind a firewall, however anything that we initiate from inside is
> allowed. I pretty much used Devin's example straight from the DVD,
>
>  put "mysql" into tType
>   put "jpatten.on-rev.com" into tHost
>   put "jpatten_theDB" into tDB
>   put "jpatten_elearn" into tUser
>   put "theDBuser_passwd" into tPass
>   put revOpenDatabase(tType,tHost,tDB,tUser,tPass) into tConnID
>   put tConnID


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



More information about the use-livecode mailing list