Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by Brianga · Oct 29, 2014 at 05:20 PM · mysqlphpsql

My code to php -> sql in PC good, in Android not work. plese fast

On my computer if the code works, but when I run on my android does not work (if I have internet access in the Manifest). here my code C #

 public class LoginMenu : MonoBehaviour {
     public TextMesh Debugt;
     string loginURL = "keep.com.co/DepartamentoDesarrollo/Arthur/ApplicacionMovil/login.php";
 
     string username = "";
     string password = "";
     string label = "";
 
     void OnGUI() {
         //GUI.Window (0, new Rect (Screen.width / 4, Screen.height / 4, Screen.width / 2, Screen.height / 2 - 70), LoginWindow, "Login");
         GUI.Label (new Rect (140, 40, 130, 100), "~~~~Username~~~~");
         username = GUI.TextField(new Rect(25, 60, 375, 30), username);
         GUI.Label (new Rect (140, 92, 130, 100), "~~~~~Password~~~~");
         password = GUI.PasswordField (new Rect (25, 115, 375, 30), password, '*');
         
         if(GUI.Button (new Rect (25, 160, 375, 50), "Login")){
             StartCoroutine (handleLogin (username, password));}
         GUI.Label (new Rect(55, 222, 250, 100), label);
     }
 
     void LoginWindow(int windowID) {
 
     }
     IEnumerator handleLogin(string username,string password){
         string loginURl = this.loginURL + "?username=" + username + "&password=" + password;
         WWW loginReader = new WWW (loginURl);
         yield return loginReader;
         if (loginReader.text == "successsuccess") {
             Debug.Log ("correcto"); Debugt.text = "D: "+"Correcto";
         } 
         if (loginReader.text == "successNope") {Debug.Log("incorrecto");Debugt.text = "D: "+"incorrecto";    }
         Debug.Log (loginReader);
         Debugt.text = "D: "+loginReader.text.ToString();
     }
 }





help my if for my Job :( ( i need in Android and iOS)

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Brianga · Oct 29, 2014 at 06:12 PM 0
Share

yes this work. example: http://keep.com.co/DepartamentoDesarrollo/Arthur/Applicacion$$anonymous$$ovil/login.php?username=A1&password=A1

this return: success ( A1 and A1 in my data base )

in PC and unity work, in android not return

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by Bunny83 · Oct 29, 2014 at 05:29 PM

shouldn't your URL has a scheme? Something like:

 string loginURL = "http://keep.com.co/DepartamentoDesarrollo/Arthur/ApplicacionMovil/login.php";

Btw: "does not work" is no description of that happens. Have you checked your "loginReader.error"? Does it contain an error message?

Comment
Add comment · Show 6 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Brianga · Oct 29, 2014 at 06:31 PM 0
Share

yes this work. example: http://keep.com.co/DepartamentoDesarrollo/Arthur/Applicacion$$anonymous$$ovil/login.php?username=A1&password=A1

this return: success ( A1 and A1 in my data base )

in PC and unity work, in android not return :((

avatar image Bunny83 · Oct 30, 2014 at 02:36 AM 0
Share

@$$anonymous$$ga: As i said, have you checked "loginReader.error"? If loginReader.text is null or an empty string you probably got some kind of error which you can ready from the loginReader.error property.

At the company i worked we also had a lot server communication for payment, user accounts, game data, ... And we never had a case where you didn't get "anything" from a WWW call.

All your WWW stuff should actually do something like this:

 // [...]
 WWW loginReader = new WWW (loginURl);
 yield return loginReader;
 if (!string.IsNullOrEmpty(loginReader.error))
 {
     Debug.LogError("WWW request has failed: " + loginReader.error);
     Debugt.text = "D: "+"WWW request has failed: " + loginReader.error;
 }
 else if (loginReader.text == "successsuccess")
 {
     Debug.Log ("correcto"); Debugt.text = "D: "+"Correcto";
 }
 else if (loginReader.text == "successNope")
 {
     Debug.Log("incorrecto");Debugt.text = "D: "+"incorrecto";
 }

There are hundreds of reasons why a web request might fail. The error returned should at least give you a hint.

avatar image Brianga · Oct 30, 2014 at 03:24 AM 0
Share

@Bunny83 tomorrow i test this. you tested WWW in Android? my proble only in Android :( , i testing in PC return success. in my Android manifest permiss.. to internet conect

avatar image Bunny83 · Oct 30, 2014 at 04:46 PM 0
Share

@$$anonymous$$ga: Just reinstalled my Android sdk and did a quick testbuild on my nexus. It works fine. It returns the same as when executed in the editor or even when i input the URL in my addressbar. In case of username / password == A1 / A1 i get:

 "empiezasi entrasuccesssuccess"

in case i use a wrong password / name i get:

 "empiezasi entrasuccessNope"

Note: "empiezasi entrasuccesssuccess" does not equal "successsuccess", obviously. So your code won't work with that data. So do one of these:

  • change the PHP to only return "successsuccess" or "successNope"

  • change your C# script to expect "empiezasi entrasuccesssuccess" or "empiezasi entrasuccessNope"

  • change your C# script to search for the partial string "successsuccess". This however is not recommended since it can be compromised.

I've suggested the changes in order from most likely to not recommended, however all 3 changes would work.

If you don't get "empiezasi entrasuccesssuccess" or "empiezasi entrasuccessNope" at all, again, you should check the error property and display it's content. $$anonymous$$aybe you don't have internet on your Android device? If you are inside a company, they might have strange firewall / router settings for the WLAN. As i said, there are hundreds of possibilities.

avatar image Brianga · Oct 31, 2014 at 03:07 AM 0
Share

Oh man thanks, debug.error return a error, the solution is in android is necesary http:// thanks friend :)

Show more comments

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Unity to PHP/MySQL: password and username security 1 Answer

WWW class and PHP security issues 1 Answer

When built for web player, my php doesn't return the datatable. Works just fine in standalone build and while editing. 1 Answer

HOW Unity store game saves? Are mySQL a valid option to store such data? How about javascript framework or php? 0 Answers

Is it possible to create GameObjects dinamically from a server? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges