Hello,
I have been stuck on this problem for ages now, and I’ve read many threads but nothing solved it so far.
It shouldn’t be so hard so maybe someone can tell me if I’m doing it wrong somewhere? I’m still a beginner with unity…
I have a webplayer hosted there: http://charles-perain.com/charlesjohn/WebPlayer/WebPlayer.html
Inside the scene is a GUI text which is supposed to display some database information (the database is on the same server).
Here is the script linked to the gui text:
var myUrl="http://localhost/charlesjohn/user.php";
function Start() {
yield StartCoroutine("getInfos");
}
function getInfos() {
gameObject.guiText.text = "Loading...";
hs_get = WWW(myUrl);
yield hs_get;
if(hs_get.error) {
Debug.Log("OUPS: "+hs_get.error);
gameObject.guiText.text = hs_get.error;
} else {
gameObject.guiText.text = hs_get.text;
Debug.Log(hs_get.text);
}
}
and here is my php file:
<?php
$link = mysql_connect(blablabla server user and password) or die(mysql_error());;
mysql_select_db("blablabla database") or die(mysql_error());;
$query = 'SELECT * FROM player ORDER BY player_id ASC';
$result = mysql_query($query);
while($line = mysql_fetch_assoc($result))
{
echo "Player".$line["player_id"].": ".$line["player_name"]."\n";
echo "PA: ".$line["player_energy"]."\n";
echo "HP: ".$line["player_health"]."\n";
echo "Position x: ".$line["player_position_x"]."\n";
echo "Position y: ".$line["player_position_y"]."\n";
echo "Position z: ".$line["player_position_z"]."\n";
echo "\n";
}
mysql_close($link);
?>
The result? “No valid crossdomain.xml policy was found”
Of course I put a crossdomain.xml file at the root, encoded in UTF8:
<?xml version="1.0" encoding="UTF-8"?>
<cross-domain-policy>
<allow-access-from domain="*" to-ports="*"/>
</cross-domain-policy>
I checked: http://charles-perain.com/crossdomain.xml and it’s there…
I’m desperate
Any help would be useful!
Thanks