cant connect to MySQL database

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
pidobearBUSsb9q
Posts: 34
Joined: Fri Jul 13, 2012 8:40 am

cant connect to MySQL database

Post by pidobearBUSsb9q » Fri Jul 27, 2012 8:56 am

global gConnID

//connection to DB
on connectToDB
put the dbhost of me & ":" & the dbport of me into tHost
put revOpenDatabase(the dbtype of me,tHost,the dbname of me,the dbUser of me, the dbPasswd of me) into tConxn

# it's a good idea, but not required, to check for a successful connection here
if tConxn is a number then
put tConxn into gConnID
return empty
else
put "Unable to connect to database '" & the dbName of me & "': " & tConxn into tErrMsg
answer error tErrMsg as sheet
put empty into gConnID
return tErrMsg
exit to top
end if
end connectToDB

//disconnect from DB
on closeDB pConnID
revCloseDatabase pConnID

# this ensures that you'll never have a left-over connection number in the global var
if pConnID = gConnID then
put empty into gConnID
end if
end closeDB

i use the code above but i cant connect to the database. it returns error

thanks for your help

CHeers :D :D :D :D :D :D

bangkok
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 937
Joined: Fri Aug 15, 2008 7:15 am

Re: cant connect to MySQL database

Post by bangkok » Fri Jul 27, 2012 9:41 am

pidobearBUSsb9q wrote: i use the code above but i cant connect to the database. it returns error
first, you should tell us... what is the error you get. That would help. :)

second, the code you use is too complicated (from a debuging point of view).

Use something more straight :

Code: Select all

put revOpenDatabase("MySQL","XX.XXX.XX.XX","NameOfMyDB","Mylogin","Mypassword") into tConxn
if tConxn is not a number then answer tConxn
Voila. Those 2 lines will tell you if you have a DB problem (connexion, network, wrong password whatever) or a script issue.

pidobearBUSsb9q
Posts: 34
Joined: Fri Jul 13, 2012 8:40 am

Re: cant connect to MySQL database

Post by pidobearBUSsb9q » Fri Jul 27, 2012 10:11 am

bangkok wrote:
pidobearBUSsb9q wrote: i use the code above but i cant connect to the database. it returns error
first, you should tell us... what is the error you get. That would help. :)

second, the code you use is too complicated (from a debuging point of view).

Use something more straight :

Code: Select all

put revOpenDatabase("MySQL","XX.XXX.XX.XX","NameOfMyDB","Mylogin","Mypassword") into tConxn
if tConxn is not a number then answer tConxn
Voila. Those 2 lines will tell you if you have a DB problem (connexion, network, wrong password whatever) or a script issue.
Hi sorry i miss that bad
i try your code
it return Cant connet to Mysql server on "myserver" (0)

thank for your help :D :D :D :D

Klaus
Posts: 14198
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: cant connect to MySQL database

Post by Klaus » Fri Jul 27, 2012 12:34 pm

Hi

will delete the other thread now.

Please add this line and tell us whqt the ANSER Dialog will tell you:

Code: Select all

on connectToDB
  put the dbhost of me & ":" & the dbport of me into tHost
  put revOpenDatabase(the dbtype of me,tHost,the dbname of me,the dbUser of me, the dbPasswd of me) into tConxn
  ANSWER tConxn
...
And make sure all those custom properties (the xxx of me) contain correct values!

Best

Klaus

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: cant connect to MySQL database

Post by Mark » Fri Jul 27, 2012 2:08 pm

Hi,

Apparently, you don't understand that the dbtype of me,tHost,the dbname of me,the dbUser of me and the dbPasswd of me are properties of an object. The object is what "me" refers to. You can't simply copy and paste the code as it won't work. You need to enter the correct host address, database type and name, port number, user name and password. I wonder if you even installed MySQL?

Kind regards,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

pidobearBUSsb9q
Posts: 34
Joined: Fri Jul 13, 2012 8:40 am

Re: cant connect to MySQL database

Post by pidobearBUSsb9q » Sat Jul 28, 2012 6:43 am

Mark wrote:Hi,

Apparently, you don't understand that the dbtype of me,tHost,the dbname of me,the dbUser of me and the dbPasswd of me are properties of an object. The object is what "me" refers to. You can't simply copy and paste the code as it won't work. You need to enter the correct host address, database type and name, port number, user name and password. I wonder if you even installed MySQL?

Kind regards,

Mark
Ya i input those values in the properties and they are getting it when i run the program but its just cant go through

the MySQL server is created by my company using phpmyadmin. i have no control over that as i am just an intern

Thanks
:D :D :D :D

pidobearBUSsb9q
Posts: 34
Joined: Fri Jul 13, 2012 8:40 am

Re: cant connect to MySQL database

Post by pidobearBUSsb9q » Sat Jul 28, 2012 6:44 am

Klaus wrote:Hi

will delete the other thread now.

Please add this line and tell us whqt the ANSER Dialog will tell you:

Code: Select all

on connectToDB
  put the dbhost of me & ":" & the dbport of me into tHost
  put revOpenDatabase(the dbtype of me,tHost,the dbname of me,the dbUser of me, the dbPasswd of me) into tConxn
  ANSWER tConxn
...
And make sure all those custom properties (the xxx of me) contain correct values!

Best

Klaus
ya have checked countless times,
i am very sure they are correct as they are provided from the full time staff in the company as i am an intern.

Thanks
:D :D :D :D :D

bangkok
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 937
Joined: Fri Aug 15, 2008 7:15 am

Re: cant connect to MySQL database

Post by bangkok » Sat Jul 28, 2012 10:21 am

pidobearBUSsb9q wrote: ya have checked countless times,
i am very sure they are correct as they are provided from the full time staff in the company as i am an intern.
OK. Do you confirm that the MySQL Server you try to access is distant (hosted on a server somewhere on the Internet) or on your local network ?

If that's the case, you need :
-to check if the MySQL Server does accept "remote connexion" (it's an option usually found in PHPMyAdmin)
That's the first step. Usually for security purposes MySQL server hosted do not accept remote connexions.

-to check the properties of the login/password you are using to access the database.

pidobearBUSsb9q
Posts: 34
Joined: Fri Jul 13, 2012 8:40 am

Re: cant connect to MySQL database

Post by pidobearBUSsb9q » Sun Jul 29, 2012 10:16 am

bangkok wrote:
pidobearBUSsb9q wrote: ya have checked countless times,
i am very sure they are correct as they are provided from the full time staff in the company as i am an intern.
OK. Do you confirm that the MySQL Server you try to access is distant (hosted on a server somewhere on the Internet) or on your local network ?

If that's the case, you need :
-to check if the MySQL Server does accept "remote connexion" (it's an option usually found in PHPMyAdmin)
That's the first step. Usually for security purposes MySQL server hosted do not accept remote connexions.

-to check the properties of the login/password you are using to access the database.
Hi

i will check with the staff of the company about the MySQL server first thing tomorrow morning

what do you mean by the properties?

pidobearBUSsb9q
Posts: 34
Joined: Fri Jul 13, 2012 8:40 am

Re: cant connect to MySQL database

Post by pidobearBUSsb9q » Mon Jul 30, 2012 3:28 am

Hey guys

Great News it working

Thanks for all your help and your time
Greatly appreciated :D

Cheers
:D :D :D :D :D

Klaus
Posts: 14198
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: cant connect to MySQL database

Post by Klaus » Tue Jul 31, 2012 3:14 pm

Would you mind telling us what the problem was? 8)

Post Reply