Page 1 of 1

MySQL on Android

Posted: Fri Dec 25, 2015 6:15 pm
by Jamie37
Hello,

I have got the code below which connects to MySQL database and checks for a username and password. However it works on windows fine but when I use it on an android device I get the error 'Cant connect to TCP/IP socket (13)'. I dont really kinow why its saying this and I have checked the tick box for MySQL in the stand alone application settings. Its only a local database for a college prohjec tim doing so does not need to be too complicated.

Hopefully somebody can help. Below is the code

Code: Select all

on loginCheck
   -- 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 "address" into tDatabaseAddress
    put "applogininfo" into tDatabaseName
    put "user" into tDatabaseUser
    put pass" 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
    else
        put empty into gConnectionID
        answer error "Unable to connect to the database:" & cr & tResult
     end if
     
     //SELECTS USER DATA FROM DATABASE AND PUTS THEM INTO VARIABLES 'theUserData & thePassData'
     
     put "SELECT Username FROM userpass" into theUser
     put revDataFromQuery(,,gConnectionID,theUser) into theUserData
     put "SELECT Password FROM userpass" into thePass
     put revDataFromQuery(,,gConnectionID,thePass) into thePassData
      
      //CHECKS TO SEE IF THE INPUTS MATCH THE DATABASE RECORDS
   
     if theUserData = the text of field "username" and thePassData = the text of field "password"  then
     go to card accessed
      else
         answer "Incorrect username or password. Please try again."
         exit to top
         end if
end loginCheck
Thanks
Jamie

Re: MySQL on Android

Posted: Fri Dec 25, 2015 6:30 pm
by ClipArtGuy
Have you also checked the "internet" option in android standalone settings? Also try putting "MySQL" as "mysql", I think it may need to be lower case.

Re: MySQL on Android

Posted: Sat Dec 26, 2015 12:59 pm
by Klaus
ClipArtGuy wrote:Also try putting "MySQL" as "mysql", I think it may need to be lower case.
Yep, since iOS and Android have a case-sensitive OS, this is mandatory!
Haven't we been there before, Jamie? 8)