I need to create a custom MySQL app - can I use LiveCode?

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
karmacomposer
Posts: 361
Joined: Wed Apr 27, 2011 2:12 pm

I need to create a custom MySQL app - can I use LiveCode?

Post by karmacomposer » Mon Aug 11, 2014 8:30 pm

Simply put, can LiveCode be used to access MySQL databases and perform database functions - like adding up all fields to get a value (queries).

Thank you for your answer. I do have SQL Yoga, but not sure if it works with the newest version of LiveCode.

Mike

karmacomposer
Posts: 361
Joined: Wed Apr 27, 2011 2:12 pm

Re: I need to create a custom MySQL app - can I use LiveCode

Post by karmacomposer » Mon Aug 11, 2014 8:59 pm

I found a MySQL LiveCode tutorial. I entered this onto a button script:

Code: Select all

on mouseUp
    -- use a global variable to hold the connection ID so other scripts can use it
    global gConnectionID
    
    -- set up the connection parameters - edit these to suit your database
    put "tampaschooloutfitters.com" into tDatabaseAddress
    put "frankg_gccasshopdb" into tDatabaseName
    put "frankg_username" into tDatabaseUser
    put "xxxxxxxxxx" into tDatabasePassword
    
    -- connect to the database
    put revOpenDatabase("MySQL", tDatabaseAddress, tDatabaseName, tDatabaseUser, tDatabasePassword) into tResult
    
    -- check if it worked and display an error message if it didn't
    -- & set the connection ID global
    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
It does not connect properly. Normally, I would use localhost as the server host, but this is running as an app and not on the web, so how do I connect to the database and get a successful connection? I am on a solid wifi connection, so i do have internet. I also have the connection details (username, password, database name, domain, etc). Not sure what I am doing wrong.

Obviously, I did not put the actual password, as this is a client database. Also, username is incorrect on purpose. For added security, I did not put the actual username either. In the actual script, all database login details are accurate.

Mike

karmacomposer
Posts: 361
Joined: Wed Apr 27, 2011 2:12 pm

Re: I need to create a custom MySQL app - can I use LiveCode

Post by karmacomposer » Mon Aug 11, 2014 9:20 pm

One problem I see is that the password to the database has a " in it. How do I format the password to account for the " symbol?

For example, the code is something like:

Code: Select all

put "eeY23"g4dfB" into tDatabasePassword
(no, this is not the actual password)

Note the " in the password. How do I format this properly so it works?

Mike

karmacomposer
Posts: 361
Joined: Wed Apr 27, 2011 2:12 pm

Re: I need to create a custom MySQL app - can I use LiveCode

Post by karmacomposer » Mon Aug 11, 2014 9:35 pm

I figured out that putting "aaaa" & quote & "bbbb" would result in "aaaa"bbbb".

Hence,

Code: Select all

put "eeY23" & quote & "g4dfB" into tDatabasePassword
should be the correct string.

Is this accurate?

Doing it still resulted in no access to the database. I KNOW the other info is all correct.

Mike
Last edited by karmacomposer on Mon Aug 11, 2014 9:36 pm, edited 1 time in total.

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

Re: I need to create a custom MySQL app - can I use LiveCode

Post by sefrojones » Mon Aug 11, 2014 9:36 pm

Try this:

Code: Select all

  put "eeY23"&quote&"g4dfB" into tDatabasePassword


--Sefro

karmacomposer
Posts: 361
Joined: Wed Apr 27, 2011 2:12 pm

Re: I need to create a custom MySQL app - can I use LiveCode

Post by karmacomposer » Mon Aug 11, 2014 9:37 pm

sefrojones wrote:Try this:

Code: Select all

  put "eeY23"&quote&"g4dfB" into tDatabasePassword


--Sefro
I did. No love.

What am I doing wrong?

Mike

karmacomposer
Posts: 361
Joined: Wed Apr 27, 2011 2:12 pm

Re: I need to create a custom MySQL app - can I use LiveCode

Post by karmacomposer » Mon Aug 11, 2014 9:50 pm

Again, the server that hold the database is online at www.tampaschooloutfitters.com

Is there a special procedure for that? Do I need to make some kind of exception on the server for my local IP?

Mike

karmacomposer
Posts: 361
Joined: Wed Apr 27, 2011 2:12 pm

Re: I need to create a custom MySQL app - can I use LiveCode

Post by karmacomposer » Mon Aug 11, 2014 9:59 pm

I got it. I had to add my IP address to the web host to accept my connection.

Thanks for your help.

Mike

Post Reply