Client to remote db?

I’m still very green, so forgive me if my question is glaringly obvious.

What I would like to do is: make a simple applescript app, which fetches information from a mySql database on the web.

Example: Let’s say I’m building a quote app, which hooks up to a database and fetches a new quote every time the user clicks a button. The idea being that if everyone is using the same db, everyone has the most current information, in this case the latest quotes.

I’ve been googling, reading, trying, failing, scratching my chin, pulling my hair, and I just can’t figure it out. So, is there some easy way to do this, that I just can’t see? Or is it a little more complicated?

ETA: Dang. I apologize for posting in the OS X forum (total brain fart). Hope you’ll help me out anyway.

It’s not trivial. But of course it can be done. Personally I would consider to set up a MySQL database on a webserver containing the various quotes. Then you would need to create a special CGI script (written in e.g. Ruby, Python, Perl) allowing your local client application to retrieve information from the database through XML-RPC or/and SOAP requests, as AppleScript supports this protocol.

Challenge :wink:

I see. Thank you! This gives me the direction I need, even if it is a little more work, than I was hoping for. :slight_smile:

Do you have the part for getting the quote from the web server? Something like this?

repeat
	try
		tell application "http://boyzoid.com/comp/randomQuote.cfc"
			set aQuote to call soap {method name:"GetQuote", parameters:{HTMLFormat:false}}
		end tell
		set aList to |item| of aQuote
		repeat with anItem in aList
			if |key| of anItem is "AUTHOR" then
				set auth to value of anItem
			end if
			if |key| of anItem is "QUOTE" then
				set quot to value of anItem
			end if
		end repeat
		set ourQuote to quot & return & " -- " & auth
	on error anError
		set ourQuote to false
	end try
	
	set B to button returned of (display dialog ourQuote buttons {"Keeper", "Another", "OK"} default button 2)
	if B is "OK" then
		exit repeat
	else if B is false then
		if (button returned of (display dialog "Something screwed up getting the quote" buttons {"Try Again", "Quit"})) is "Quit" then exit repeat
	else if B is "Keeper" then
		set the clipboard to ourQuote
		display dialog "The quote is in the clipboard"
	end if
end repeat

You might also want to check out this post. It has example code to handle what you are wanting
to do with modification for your specific requirements. The PHP code is very simple.
If you are not familiar with PHP a few web tutorials should get you comfortable enough
to make the necessary changes.

Good luck!

Craig

Can I just say that you guys all ROCK! Thank you so much.

Happy holidays, too. :slight_smile: