Page 1 of 1

CPanel

Posted: Mon Sep 24, 2018 5:23 pm
by jwtea
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
   

Re: CPanel

Posted: Mon Sep 24, 2018 7:14 pm
by SparkOut
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?

Re: CPanel

Posted: Mon Sep 24, 2018 7:18 pm
by ClipArtGuy
maybe it's the extra apostrophe in this put statement?

Code: Select all

put "mp04.projectsbit.org" into tDatabaseAddress'

Re: CPanel

Posted: Mon Sep 24, 2018 7:21 pm
by matthiasr
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

Re: CPanel

Posted: Mon Sep 24, 2018 7:31 pm
by ClipArtGuy
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

Re: CPanel

Posted: Mon Sep 24, 2018 7:34 pm
by matthiasr
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

Re: CPanel

Posted: Mon Sep 24, 2018 7:39 pm
by ClipArtGuy
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.

Re: CPanel

Posted: Tue Sep 25, 2018 3:34 pm
by jwtea
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 ~ ~

Re: CPanel

Posted: Tue Sep 25, 2018 3:48 pm
by matthiasr
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

Re: CPanel

Posted: Tue Sep 25, 2018 4:02 pm
by jwtea
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)