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 ikelaiah · Jul 19, 2013 at 06:45 AM · wwwphp

Retreiving php value using WWW

I have the following php script and would like to get the echo into unity. However, when I do www.text ,it gives me the HTML text instead of the echoed value. Can someone point out to me where did I go wrong?

 <?php
 $a = 'apple';
 $b = 'cider';
 $c = 'drink';
 echo $c;
 ?>

In Unity I use:

 var www : WWW = new WWW("My address");
 yield www;
 Debug.Log(www.text);

It gives me the whole html page after www.text.

EDIT: It looks like someone had a similar problem but not solved.

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

1 Reply

· Add your reply
  • Sort: 
avatar image
2
Best Answer

Answer by Kiloblargh · Jul 19, 2013 at 07:04 AM

That's what www.text should give you, "drink" followed by the whole page.

You could use String.Split to trim off everything but the first word.

Or you can use WWWForm with $POST to just send a value to the PHP script and get the echo value back.

Comment
Add comment · Show 4 · 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 ikelaiah · Jul 19, 2013 at 07:11 AM 0
Share

I don't see "drink." According to this you simply use the WWW.text method to get the echoed value. Btw, the first word that I get is...

 <!DOCTYPE HT$$anonymous$$L PUBLIC "-//W3C//DTD HT$$anonymous$$L 3.2 Final//EN">

...but I have no HT$$anonymous$$L at all in my .php file

avatar image Kiloblargh · Jul 19, 2013 at 03:35 PM 1
Share

Can you post the link to "$$anonymous$$y address"?

avatar image Bunny83 · Jul 19, 2013 at 05:03 PM 0
Share

Yes, are you sure that you are actually requesting your php file?

avatar image ikelaiah · Jul 19, 2013 at 09:11 PM 0
Share

@kiloblargh @ Bunny83 Your comments solved my problem. I exposed the wrong link in the Inspector, but I only changed the link (url) in the code. The wrong link does not contain the .php file, only pointed to the folder where the .php file was. After making sure the variable in the inspector point to the right address and "..requesting your php file." the problem was solved! Thank you! I like to upvote your comments but unfortunately my rating is too low to do that. Greatly appreciated!

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

16 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

Related Questions

connecting to php? 2 Answers

Network class vs php for authoritative actions? 1 Answer

Retrieving varibale values from a php script? 1 Answer

Why is my PHP echo returning entire PHP file after WWW request? 1 Answer

How do I know that php server is available? (C# script) 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