PHP array.

Anyone know how I could retreive a mySQL array through PHP to Unity?

The server side highscore script from the Unify wiki is a good example of how to do this.

You can echo the results and parse it anyway you want it.

I prefer use the json_encode function wich takes a php array and returns it as a json array formated string. Then I use a c# json parser that converts this string to a hashtable or an arraylist.

339443–11879–$json_212.cs (13.1 KB)

I mean retreive multiple data from the PHP script

Example:

PHP:

echo "Hello!"
echo "Goodbye!"

Then have Unity Debug.Log those echoes one by one so the console reads

Hello!
UnityEngine.Debug:Log(Object)
Goodbye!
UnityEngine.Debug:Log(Object)

Check out the WWW and the data property.

The idea is to combine it also into a single string, and then parse it in Unity.

For example, in PHP:

echo $var1 . ":" . $var2 . ":" . $var3;

// prints: Tom:Frank:Lemmy

Then, in Unity:

string data = [url]www.data;[/url]

string[] split = data.Split(":");

// split[0] = Tom
// split[1] = Frank
// etc

The BEST way to do this is using the JSON encryption/decryption, which is what Azul was suggesting. My example is a very, very simple method.

Thank you tempest, I am aiming for the simplest ways I can get things done that work efficiently. Then when I learn more I can go back and mod them to be more secure/faster.

Hmm Tempest could I have a javascript version of that?

	var str : String = "tom.mom.mot";
    var arr = new Array();	
	arr = str.Split(".", [0]);

// arr[0] = tom
// arr[1] = mom

hi tempest . i have the same problem as like above , i getting values from database , by using Php code
it returns the value as
for example:
2.165:2.568:2.568:2.548:2.4536
i am using the www class to get the data
var url = “http://******************** “;
var hs_get : WWW = new WWW(url);
var wer = new Array();
yield hs_get;
if(hs_get.error)
{ error message}
else
{
wer = hs_get.data.Split(”:”,[0]);

}
it shows the error of NO appropriate version of String.Split for the argument list “(String.(int))” was found

i need to convert the returned values from database to integer array and have to show up them in gui
pls help me to solve the problem …!!
thanks in advance
arun