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 appels · Jul 31, 2010 at 10:27 PM · wwwdatabasemysqlphp

www php send data to mysql

Hi,

i managed to retrieve my data from mysql via php but i can't figure out how to send data to mysql via php. I have the php file and thats working when i test it in the browser. When i do this in unity i see that my values don't get posted to the php url. My output is showing :

UPDATE unity SET color = '' WHERE firstname = '' AND lastname = ''

the values are missing.

My script :

function setColor (fname : String, lname : String, newColor : String)
{
    var form = new WWWForm();
    form.AddField("firstname", fname);
    form.AddField("lastname", lname);
    form.AddField("color", newColor);
    var setData = new WWW(writeColorURL, form);
    yield setData;
    if(setData.error)
    {
        Debug.Log(setData.error);
    }
    else
    {
        Debug.Log(setData.text);
        Debug.Log("Data has been sent to mysql");
    }
}

What am i doing wrong ? Thanks.

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
1

Answer by appels · Aug 01, 2010 at 12:48 AM

ok, i found my problem. it was the url that needed to be constructed in the right format. this was my solution : var createURL = writeColorURL + "?firstname=" + fname + "&lastname=" + lname + "&color=" + newColor; according the php syntax

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 Bunny83 · Aug 16, 2011 at 12:56 PM 0
Share

To sum up: Your php script doesn't read post data but uses get parameters ins$$anonymous$$d.

You should accept your answer to close this question.

avatar image
0

Answer by Plato · Feb 04, 2011 at 11:16 AM

As a little optimization advice.

unity+php+mysql is unsafe architecture for storing data - header (get or post) can be easily intersepted by cheaters.

Instead of using php scripts I suggest you download .net mysql connector (http://www.mysql.com/downloads/connector/net/) and use C# scripts to communicate with you database.

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 mikeytrw · Aug 16, 2011 at 12:44 PM 3
Share

I'm sorry, but I completely disagree.

If your sending $$anonymous$$ySQL data directly, your $$anonymous$$ySQL connection details will need to be stored in the source code where it may be fairly trivial to extract (I'm not sure how Unity3D built projects work - but this is the case for iPhone apps).

This traffic can also be intercepted far more easily than SSL secured HTTP requests, and once it is intercepted the attacker has direct access to your database, allowing them complete access to your underlying database infrastructure and completely wreck havoc.

Yes, the $$anonymous$$ySQL traffic will be using the $$anonymous$$ySQL protocol, but it's completely unencrypted - your sending raw SQL statements directly to the database, in terms of security this is ludicrous.

Indeed it is possible to use SSL over a $$anonymous$$ySQL connection but this puts you back in the same bracket as HTTP to PHP, except that if the connection is broken your completely exposed to a vicious attack.

$$anonymous$$uch better to implement a secure tamper-proof PHP backend, with server-side validation and verification.

avatar image Bunny83 · Aug 16, 2011 at 12:55 PM 0
Share

@mikeytrw: absolutely! All scripts in your build can be easily decompiled with ILSpy or other reflector programs. Storing sensitive connection data in your scripts will end in a disaster.

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Unity - MySQL data loss 0 Answers

Upload audio file into mysql database 0 Answers

How to get different variables from PHP page ? (example included)... 1 Answer

Using PHP to generate objects or list in Unity with C# 2 Answers

Web Player and database 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