CPanel

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

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
jwtea
Posts: 66
Joined: Fri Mar 23, 2018 2:01 am

CPanel

Post by jwtea » Mon Sep 24, 2018 5:23 pm

Hello, i am trying to connect my database from Cpanel ~ ~~

I tried the code below but still failed to connect ~

Code: Select all

put "mp04.projectsbit.org" into tDatabaseAddress'
put "runrev_test" into tDatabaseName
put "fakeuser" into tDatabaseUser
put "fakepassword" into tDatabasePassword
   
    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
   

SparkOut
Posts: 2852
Joined: Sun Sep 23, 2007 4:58 pm

Re: CPanel

Post by SparkOut » Mon Sep 24, 2018 7:14 pm

cPanel is not LiveCode so I am not sure what you are trying to do and how you are trying to do it.
Is the code you supplied a part of a script from LiveCode server?
The database name looks a bit unlikely- is that a fake name too or does it really look like that when you use (say) phpMyAdmin?

ClipArtGuy
Posts: 253
Joined: Wed Aug 19, 2015 4:29 pm

Re: CPanel

Post by ClipArtGuy » Mon Sep 24, 2018 7:18 pm

maybe it's the extra apostrophe in this put statement?

Code: Select all

put "mp04.projectsbit.org" into tDatabaseAddress'

matthiasr
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 190
Joined: Sat Apr 08, 2006 7:55 am
Location: Lübbecke, Germany
Contact:

Re: CPanel

Post by matthiasr » Mon Sep 24, 2018 7:21 pm

Hi,

if i remember right, you have to allow remote access to your MySQL database to be able to access your database from a desktop app.

For security reasons the access to the database is only allowed from the localhost. So if you want to allow the access from remote then add your ip or %.%.%.% (as a wildcard) in cPanel under Remote MySQL.

This should allow to connect to the database from your Livecode desktop app.

Regards,

Matthias

ClipArtGuy
Posts: 253
Joined: Wed Aug 19, 2015 4:29 pm

Re: CPanel

Post by ClipArtGuy » Mon Sep 24, 2018 7:31 pm

As a side note, If your app is going to be distributed to users, you should probably not hardcode your database credentials into the app itself, and instead use a "middleware" script, which can be easily done in LC or PHP.

More info on middleware in this thread:

http://forums.livecode.com/viewtopic.php?t=23614

matthiasr
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 190
Joined: Sat Apr 08, 2006 7:55 am
Location: Lübbecke, Germany
Contact:

Re: CPanel

Post by matthiasr » Mon Sep 24, 2018 7:34 pm

HostM has provided a nice tutorial for how to securely connect to MySQL/MariaSQL Database from a Livecode Desktop app using a Livecode Server script on your webserver.

https://www.hostm.com/tutorials/livecod ... iadb-mysql

ClipArtGuy
Posts: 253
Joined: Wed Aug 19, 2015 4:29 pm

Re: CPanel

Post by ClipArtGuy » Mon Sep 24, 2018 7:39 pm

matthiasr wrote:
Mon Sep 24, 2018 7:34 pm
HostM has provided a nice tutorial for how to securely connect to MySQL/MariaSQL Database from a Livecode Desktop app using a Livecode Server script on your webserver.

https://www.hostm.com/tutorials/livecod ... iadb-mysql
I hadn't seen this before. Very nice, thanks for posting this.

jwtea
Posts: 66
Joined: Fri Mar 23, 2018 2:01 am

Re: CPanel

Post by jwtea » Tue Sep 25, 2018 3:34 pm

matthiasr wrote:
Mon Sep 24, 2018 7:21 pm
Hi,

if i remember right, you have to allow remote access to your MySQL database to be able to access your database from a desktop app.

For security reasons the access to the database is only allowed from the localhost. So if you want to allow the access from remote then add your ip or %.%.%.% (as a wildcard) in cPanel under Remote MySQL.

This should allow to connect to the database from your Livecode desktop app.

Regards,

Matthias
Hello Matthias!

Thank for you replies! Just want to double check in the Remote MySQL i will need to add my current ip address? or any ip address ?

PS: Sorry i'm quite new ~ ~

matthiasr
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 190
Joined: Sat Apr 08, 2006 7:55 am
Location: Lübbecke, Germany
Contact:

Re: CPanel

Post by matthiasr » Tue Sep 25, 2018 3:48 pm

You need to add the ip address from where you want to connect to the DB.
That´s the ip address you are getting from your ISP when connecting to the internet, not your local ip address.



But for security reasons you should consider to use a php or livecode server script on your webserver to do the database communication. In this case you do not need to allow remote access. I really recommend to visit the link to the HostM tutorial.

Regards,

Matthias

jwtea
Posts: 66
Joined: Fri Mar 23, 2018 2:01 am

Re: CPanel

Post by jwtea » Tue Sep 25, 2018 4:02 pm

Hello matthiasr!

Finally managed to connect to my database because of your help! :D

Because i was only trying out livecode to play around hahaha but ofcourse i will look up the HostM tutorial soon thanks 8)

Post Reply

Return to “Talking LiveCode”