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
0
Question by Mathpro · Apr 11, 2015 at 10:09 AM · c#androiddatabasemysql

Downloading data from MySql database not working on Android.

I have a very weird problem. I have an application which is supposed to get an image url and some text from a database on a server. It works perfectly on a computer but when I build it to Android it doesn't load the image nor the text. What's weirder is that my friend who is working on the same project did an almost identical script accessing a different database extracting world coordinates to spawn markers on the world map and it works on both Android and PC.

 public void callGetInfo() {
         StartCoroutine(getInfo(currentButtonText,titletext.text));
 
         StartCoroutine(getInfo(currentButtonText,"picture"));
 
     }
     
 
     public IEnumerator getInfo(string name, string data) {
     
         //print (data);
         string newURL = "grainr.net/get_cult_info.php?name=" + name.ToLower() + "&requested_data=" + data.ToLower();
         //string imgURL ="grainr.net/get_cult_info.php?name=" + name.ToLower() + "&requested_data=picture";
         //string imgURL = "http://www.themonitordaily.com/wp-content/uploads/2015/03/aplle.jpg";
         WWWForm form = new WWWForm ();
         form.AddField ("name", name.ToLower());
         form.AddField ("requested_data", data.ToLower());
         WWW getData = new WWW(newURL,form);
         yield return getData;
         if (getData.error != null){
         
         }
         else{
         
         }
         if(data == "picture")
         {
             stringReturnImageURL = getData.text;
             print(stringReturnImageURL);
             StartCoroutine(getPic(stringReturnImageURL));
         } else {
         texttext.text = getData.text;
         }
     }
 
     public IEnumerator getPic(string name) {
         print (name);
         //string imgURL ="grainr.net/get_cult_info.php?name=" + name.ToLower() + "&requested_data=picture";
         //string imgURL = "http://www.themonitordaily.com/wp-content/uploads/2015/03/aplle.jpg";
         WWW getPic = new WWW(name);
         yield return getPic;
         if (getPic.error != null){
             
         }
         else{
             
         }
         image.GetComponent<Image>().sprite = Sprite.Create(getPic.texture,new Rect(0,0,getPic.texture.width,getPic.texture.height),new Vector2(0.5f,0.5f));
     }

This is my code (Not working on any android device)

 public IEnumerator GetMarkerData (string where1,string where2, string data) {
     string login_URL = "http://grainr.net/get_marker_info.php?where_1=" + where1 + "&where_2=" + where2 + "&requested_data=" + data;
     WWWForm form = new WWWForm ();
     form.AddField ("where_1", where1);
     form.AddField ("where_2", where2);
     form.AddField ("requested_data", data);
     
     WWW loginReader = new WWW (login_URL,form);
     yield return loginReader;
     
     if (loginReader.error != null) {
         
     } else {
         
     }
     if (data == "longtitude") {
         stringReturnLongtitude = loginReader.text;
     }else if (data == "latitude") {
         stringReturnLatitude = loginReader.text;
     }else if (data == "username") {
         stringReturnUsername = loginReader.text;
     }else if (data == "id") {
         stringReturnId = loginReader.text;
     }else if (data == "count") {
         stringReturnCount = loginReader.text;
     }
     coroutineHasFinished = true;
 }

My friend's code(working on android/pc)

I need help ASAP. Thanks in advance.

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 omerh.crewlogix · May 16, 2016 at 11:29 AM 0
Share

have you completed ? i am stuck on the same problem .. not working on android

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by mole1984 · May 16, 2016 at 05:16 PM

It's not working because of url. I think it is because of "http://" . It is important to set it at the right position. watch my source/code on www.appymole.com/downloads - There it is correct and works for Android. I took It from the same wiki and have fixed it

Try it this way:

  1. delete http in your url:

    string login_URL = "www.grainr.net/get_marker_info.php?where_1="

  2. Put it in here:

    WWW loginReader = new WWW ("http://"+login_URL,form);

Comment
Add comment · Show 2 · 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 Dave-Carlile · May 17, 2016 at 06:50 PM 0
Share

Both "http://abc.def" and "http://" + "abc.def" result in exactly the same string. Unless the login_URL variable is used somewhere that requires the http to not be there then your proposed code change is meaningless.

avatar image mole1984 · May 17, 2016 at 09:36 PM 0
Share

I know. But then it works. I also can not explain why.

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Should I load all the database items on my android device? 1 Answer

Login from database in unity 0 Answers

Multiple Cars not working 1 Answer

Not allowed to connect to my database. 1 Answer

WWW Form C# on Android 0 Answers


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