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 Mktime · Aug 25, 2010 at 06:20 PM · wwwstringphp

www.data and string conversion to integer

I am new at Unity but trying to utilize www to get information from php. I have read I think almost all the forum and answer posts.

I get an error message that string is not in correct format? Can anyone help? I am send back the number 10 from php in an echo "10" - I am also wondering is there is other documentation on string parsing other than in the reference guide?

php code ->

<?php

echo "10" ?>

java code ->

This is the code:

function Start () { //var data : string; // call php page; var www : WWW = new WWW (url);

// Wait for download to complete; yield www;

// returns back string from php - not in form that is workable; speedA = www.data;

// parse command seems to work because you can hard code value for speedA; speeds = int.Parse(speedA);

}

Comment
Add comment
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

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by jashan · Aug 25, 2010 at 07:19 PM

The first thing you should to do is print www.data and see what exactly it looks like. Most likely, this is not just "10" but maybe "10 plus return" or something like that.

Something like

Debug.Log(string.Format(" x{0}x ", speedA));

should do the trick. If this prints anything else than x10x, like x10 new line x, for instance, that would be the problem. You might try String.Trim() ... that should remove whitespace:

speedA = speedA.Trim();

Of course, for that to work you have to make sure that speedA really is a string but I guess UnityScript should handle that correctly for you.

Comment
Add comment · Show 3 · 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 Mktime · Aug 25, 2010 at 09:07 PM 0
Share

I think the problem is in the www.data string not sure how to use the Trim command but will look at that.

avatar image jashan · Aug 26, 2010 at 07:07 AM 0
Share

I've edited the answer to make usage of Trim() a bit more clear. I had it in the original answer but now it should be super-easy ;-)

avatar image Wilaxxx · May 08, 2014 at 10:52 AM 0
Share

thanks for the help :D

avatar image
0

Answer by DaveA · Aug 25, 2010 at 08:30 PM

I thought int.Parse() was C#, but with .Net, learn something new every day. I just converted a JS to C#, and I was using parseInt() in JS (worked fine), replaced with int.Parse() for C#. So you might try speeds = parseInt(speedA);

Comment
Add comment · Show 1 · 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 Mktime · Aug 25, 2010 at 09:06 PM 0
Share

Thanks for the help with this this didn't work.

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

1 Person is following this question.

avatar image

Related Questions

WWW.text gets extra analytics code to the string!?! 3 Answers

Getting String From WWW 2 Answers

Retrieving varibale values from a php script? 1 Answer

How to convert a string to a type WWW 0 Answers

Php not downloading data for game on web player 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