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 /
  • Help Room /
avatar image
0
Question by BogdanVasc · Jul 15, 2017 at 03:25 PM · wwwdatabasemysqlphp

WWW not working on my PHPs

Hello. I am new to this, and I have followed the wiki tutorial "Server side highscores" in order to create a leaderboard on my server. Everything seems fine until I try to send/get the data within Unity, neither of them working properly. When I try to send data, null values are sent instead; and when I try to get it, I receive a string with content similar to a HTML script (with 'body' etc., nothing related to what I should receive). Doing these manually work without a problem. Here are the scripts:

test_insert.php ) or die('Could not connect: ' . mysql_error()); mysql_select_db('') or die('Could not select database');

     $id = mysql_real_escape_string($_GET['id'], $database);
     $msgid = mysql_real_escape_string($_GET['msgid'], $database); 
 
  
     echo $id . "\t" . $msgid;
     $query = "INSERT INTO test (id, msgid) VALUES('$id', '$msgid');";
     $result = mysql_query($query) or die('Query failed: ' . mysql_error());
 ?>

test_display.php ') or die('Could not connect: ' . mysql_error()); mysql_select_db('') or die('Could not select database');

     $query = "SELECT * FROM `test`";
     $result = mysql_query($query) or die('Query failed: ' . mysql_error());
  
     $num_results = mysql_num_rows($result);  
     for($i = 0; $i < $num_results; $i++)
     {
          $row = mysql_fetch_array($result);
          echo $row['id'] . ' ' . $row['msgid'] . '/';
     }
 ?>

Unity C#: using System.Collections; using System.Collections.Generic; using UnityEngine;

 public class phpstufftesting : MonoBehaviour {
     public string postinfolink = "http://***/test_insert.php?";
     public string getinfolink = "http://***/test_display.php";
 
     IEnumerator PostInfo(int id, string msgid){
         string post_id = postinfolink + "id=" + id + "&msgid=" + WWW.EscapeURL (msgid);
         Debug.Log (post_id);
         WWW hs_post = new WWW (post_id);
         yield return hs_post;
         if (hs_post.error != null)
             Debug.Log (hs_post.error);
     }
 
     IEnumerator GetInfo(){
         WWW hs_get = new WWW (getinfolink);
         yield return hs_get;
         if (hs_get.error != null)
             Debug.Log ("Error: " + hs_get.error);
         string info = hs_get.text;
         string[] each = info.Split ('/');
         for (int i = 0; i < each.Length; i++)
             Debug.Log (each [i]);
     }
 
     void Start () {
         StartCoroutine (PostInfo (5, "hello"));
     }
     
     // Update is called once per frame
     void Update () {
         
     }
 }
 

crossdomain.xml

 <?xml version="1.0"?>
 <!DOCTYPE cross-domain-policy SYSTEM
 "http://www.adobe.com/xml/dtds/cross-domain-policy.dtd">
 <cross-domain-policy>
     <site-control permitted-cross-domain-policies="master-only"/>
     <allow-access-from domain="*"/>
     <allow-http-request-headers-from domain="*" headers="*"/>
 </cross-domain-policy>


Retrieving data from other websites (tested for images from Google) works. Also, since I am only experimenting, I am using a free hosting service, but I don't believe this could be the problem behind this.

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

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

115 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Why is MySQL search query not returning each row in 1 index of an array? 0 Answers

i need help unity get data from php 0 Answers

Unity sql PHP script can log in with wrong password, what's wrong? 0 Answers

Money from unity to mysql db 0 Answers

display data from mysql 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