connecting to mySQL

Creating desktop or client-server database solutions?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
malin
Posts: 11
Joined: Fri Jan 09, 2015 10:44 pm

connecting to mySQL

Post by malin » Fri Jan 09, 2015 10:55 pm

on mouseUp
global gConnectionID

put "xxxxx" into tDatabaseAddress
put "xxxxxx" into tDatabaseName
put "xxxxx" into tDatabaseUser
put "xxxxx " into tDatabasePassword

-- connect to the database
put revOpenDatabase("MySQL", tDatabaseAddress, tDatabaseName, tDatabaseUser, tDatabasePassword) into tResult

if tResult is a number then
put tResult into gConnectionID
answer info "Connected to the database." & cr & "Connection ID = " & gConnectionID
else
put empty into gConnectionID
answer error "Unable to connect to the database:" & cr & tResult
end if
end mouseUp

Hi all,

I am making a public app which would connect to a MySQL database on Godaddy server.
Is there a better way to connect to it rather than the example above been thought by RunRev?
If there is, kindly help in an easy to understand term, as I am pretty new to Livecode.

Regards
Malin

Klaus
Posts: 13878
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: connecting to mySQL

Post by Klaus » Sun Jan 11, 2015 5:55 pm

Hi Malin,

1. welcome to the forum! :D

2. This is the correct forum for database question, be they local or online.
Therefore I deleted the double posting in "Internet".

3. I do not know of any OTHER way to connect to a database than "revopendatabase ..." :D

Question is, does GoDaddy allow direct connection to the db?
For security reasons most providers demand a "middleware" like PHP or Livecode-Server,
which does the actual db access stuff.


Best

Klaus

malin
Posts: 11
Joined: Fri Jan 09, 2015 10:44 pm

Re: connecting to mySQL

Post by malin » Sun Jan 11, 2015 7:13 pm

Hi Klaus,

Thank you for your reply.

My main concern is that it is not possible/advisable to connect to database on godaddy directly like tought on the lessons sold by livecode.

But the lessons have been so helpful and educative that i can easily query test tables.

My question:

1. if i use webservice, does i just use it inplace of the connection of the normal connection parameters to database and other query language in the script will remain the same or do i need to rewrite the whole script?
2. if i need to rewrite the whole code, is there a lesson or resource that really teaches about using webservices and quering table.
3. is livecode hosting package as good as other commercial webhost (eg godaddy)

Klaus
Posts: 13878
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: connecting to mySQL

Post by Klaus » Mon Jan 12, 2015 1:52 pm

Hi Malin,
malin wrote:1. if i use webservice, does i just use it inplace of the connection of the normal connection parameters to database and other query language in the script will remain the same or do i need to rewrite the whole script?
well, that depends on the webservice you are going to use!
If you can use Livecode Server, then the syntax is identical.
No idea about PHP etc., but that will sure make a complete rewrite neccessary!
Check sites like these to learn about using PHP: http://www.w3schools.com/php/default.asp
malin wrote:2. if i need to rewrite the whole code, is there a lesson or resource that really teaches about using webservices and quering table.
For some LC server examples, check this website: http://on-rev.com/revolution/overview/
malin wrote:3. is livecode hosting package as good as other commercial webhost (eg godaddy)
I have no idea! 8)


Best

Klaus

malin
Posts: 11
Joined: Fri Jan 09, 2015 10:44 pm

Re: connecting to mySQL

Post by malin » Mon Jan 12, 2015 3:54 pm

Thanks for your reply.

I am reading the lesson you sent me :)

One last question, as I apologize if am kind of an headache :mrgreen:

If I use livecode server with the normal DB connection lesson from livecode, is there a way to safe guard my user info... Username, password, host address... Since my fear is that they will be packaged with the app. Or ounces the app is packaged onto andriod and iPhone this information becomes encrypted?

Tack
Malin

Klaus
Posts: 13878
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: connecting to mySQL

Post by Klaus » Mon Jan 12, 2015 3:58 pm

Hi Malin,

the webservice does the db conncetion, so no username and password etc. in your app at all!
Are you sure you understand the principle of using a webservice?


Best

Klaus

malin
Posts: 11
Joined: Fri Jan 09, 2015 10:44 pm

Re: connecting to mySQL

Post by malin » Mon Jan 12, 2015 4:20 pm

Hello again

Well am trying to understand it, but the lesson livecode has on it is not enough to dabble into it.

I am going thru lessons on udemy to see if I can find something suitable, but it's tough since even if I know it, there seems to be no lessons regarding implementing it with on livecode.

Have you any advice?

Thanks

Klaus
Posts: 13878
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: connecting to mySQL

Post by Klaus » Mon Jan 12, 2015 4:37 pm

Hi Malin,
malin wrote:Well am trying to understand it, but the lesson livecode has on it is not enough to dabble into it.
see the database example of Livecode server, you do not provide anything like pwd or username,
but the webpage/webservice gets the database content and displays it in your browser nevertheless!
malin wrote:Have you any advice?
No, sorry, not my "cup of tea", really...


Best

Klaus

sefrojones
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 447
Joined: Mon Jan 23, 2012 12:46 pm

Re: connecting to mySQL

Post by sefrojones » Mon Jan 12, 2015 5:26 pm

Hi Malin,

Welcome to the forums. I am not an expert in webservices or databases, but I recently set up a server script to handle fetching high score information for my app, so as not to store my credentials inside the app. The first thing you will need is LiveCode server installed on your server. I followed the instructions here:

http://activethought.net/setting-livecode-server/

I then simply moved the part of my app script that fetched high score information from the database to a LC server script. Then in my app script instead of connecting to the database directly, I used GET to connect to my script on the server, at which point I can parse the info, etc. It's a bit early and I haven't had my coffee yet, but I think this is what you are after....


--Sefro

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am
Location: Palo Alto

Re: connecting to mySQL

Post by Simon » Mon Jan 12, 2015 9:48 pm

How about this lesson;
http://lessons.runrev.com/m/4071/l/1172 ... a-database
Though that is an on-rev server it is using cPanel and I believe godaddy is the same.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

malin
Posts: 11
Joined: Fri Jan 09, 2015 10:44 pm

Re: connecting to mySQL

Post by malin » Mon Jan 12, 2015 10:11 pm

@ Sefro and Simon.

Thanks a lot.

kind regards

Post Reply

Return to “Databases”