Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 zak666 · Jun 08, 2019 at 06:06 PM · wwwform

Need help to get my www.form to work.

hey gang trying to WWW call a PHP script on me server don't see any errors on my unity script yet cant get a response from the website, and can't seem to get it to work. everything is in the right directories keep getting Debug.Log("Error Saving Your Game..." + www.text); so as far as i can see its not even being sent to the php on my site.

cant see what the error is...

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 namespace Photon.Pun.Demo.AsteroidsGame
 {
     public class AccountConnect : MonoBehaviour
     {
 
         public string UserName;
         public string Password;
 
 
         public float Xp = 10;
         public float XpMaax = 1000;
         public float Level = 1;
         public float MaxLevel = 90;
         public float Crystals = 10;
         public float Titanium = 10;
 
         public float StarFighter01;
         public float StarFighter02;
         public float StarFighter03;
         public float StarFighter04;
         public float StarFighter05;
 
        public string FinaleFileName;
 
         public bool succssfulLogin = true;
 
 
         public void NewGameData()
         {
             StartCoroutine(NewGameSave());
             FinaleFileName = UserName + Password;
         }
 
 
         // Use To Save Any Data... :)
         public void SaveGameData()
         {
             StartCoroutine(sendTextToFile());
         }
 
         //Also Use For Loggin
         public void LoadGameDataButton()
         {
             StartCoroutine(LoadGameData());
             FinaleFileName = UserName + Password;
 
         }
 
 
 
 
 
 
 
 
         //NewGameData...................
 
         IEnumerator NewGameSave()
         {
             bool succssful = true;
 
             WWWForm form = new WWWForm();
             form.AddField("UserName", FinaleFileName);
             form.AddField("Experiancepoints", "0");
             form.AddField("Level", "1");
             form.AddField("Crystals", "1100");
             form.AddField("Titanium", "1100");
             form.AddField("StarFighter01", "1");
             form.AddField("StarFighter02", "0");
             form.AddField("StarFighter03", "0");
             form.AddField("StarFighter04", "0");
             form.AddField("StarFighter05", "0");
 
             WWW www = new WWW("http://www.darkdivideonline.com/savegames/savedata.php", form);
             yield return www;
 
             if (www.error != null)
             {
                 succssful = true;
                 Debug.Log("We Got This..." + www.text);
             }
             else
             {
                 succssful = false;
                 Debug.Log("Error..." + www.text);
 
             }
 
         }
 
 
 
         //Save Game Data...................
 
         IEnumerator sendTextToFile()
         {
             bool succssful = true;
 
             WWWForm form = new WWWForm();
             form.AddField("UserName", FinaleFileName);
             form.AddField("Experiancepoints", Xp.ToString());
             form.AddField("Level", Level.ToString());
             form.AddField("Crystals", Crystals.ToString());
             form.AddField("Titanium", Titanium.ToString());
             form.AddField("StarFighter01", "1");
             form.AddField("StarFighter02", StarFighter02.ToString());
             form.AddField("StarFighter03", StarFighter03.ToString());
             form.AddField("StarFighter04", StarFighter04.ToString());
             form.AddField("StarFighter05", StarFighter05.ToString());
 
             WWW www = new WWW("http://www.darkdivideonline.com/savegames/savedata.php", form);
             yield return www;
 
             if(www.error != null)
             {
             succssful = true;
             }
             else
             {
                 Debug.Log("Error Saving Your Game..."  + www.text);
                 succssful = false;
             }
         }
 
 
 
 
 
         // Load Data...................
         IEnumerator LoadGameData()
         {
            
             WWWForm formload = new WWWForm();
             formload.AddField("UserName", FinaleFileName);
 
             WWW www = new WWW("http://www.darkdivideonline.com/loaddata.php", formload);
             yield return www;
 
             if (www.error != null)
             {
                 succssfulLogin = true;
             }
             else
             {
                 Debug.Log("Error Saving Your Game..." + www.text);
                 succssfulLogin = false;
             }
         }
         }
 }
 









PHP:

 $text1 = $_POST["UserName"];
 $text2 = $_POST["Experiancepoints"];
 $text3 = $_POST["Level"];
 $text4 = $_POST["Crystals"];
 $text5 = $_POST["Titanium"];
 
 $text6 = $_POST["StarFighter01"];
 $text7 = $_POST["StarFighter02"];
 $text8 = $_POST["StarFighter03"];
 $text9 = $_POST["StarFighter04"];
 $text10 = $_POST["StarFighter05"];
 
 if($text1 != "")
 {
 echo("Message Successfully Sent YAY!!!");
 $file = fopen("$text1.txt","w");
 fwrite($file , $text2);
 fwrite($file , $text3);
 fwrite($file , $text4);
 fwrite($file , $text5);
 fwrite($file , $text6);
 fwrite($file , $text7);
 fwrite($file , $text8);
 fwrite($file , $text9);
 fwrite($file , $text10);
 fclose($file);
 }else{
 echo("Mesasage Not Deliverd....");
 }
 
 
 ?>
Comment
Add comment · Show 2
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 Bunny83 · Jun 07, 2019 at 11:36 PM 0
Share

First of all your error checking is the wrong way round:

 if (www.error != null)
 {
     succssful = true;
     Debug.Log("We Got This..." + www.text);
 }
 else
 {
     succssful = false;
     Debug.Log("Error..." + www.text);
 }

You set succesful to true when there is an error and set it to false when there isn't an error. Also in both cases you lof www.text which makes no sense. if error is set it actually contains the error message. So if error is != null you want to actually print that error message.

avatar image zak666 Bunny83 · Jun 09, 2019 at 10:39 AM 0
Share

heya, thanks for a start, didn't even notice that, I'm not getting any error messages and it says that the script works, yet on my server nothing seems to be happening and no files are being created / written.

0 Replies

· Add your reply
  • Sort: 

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

107 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Problem with online high score 4 Answers

send xml with wwwform for youtube video upload from unity 0 Answers

Passing a curl user via WWWForm 1 Answer

Returning from Coroutine stops the Update() method. 0 Answers

Coroutine for WWW call not resuming 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