Hello, I’m new to Unity and I need help to realise a little script which can communicate with a mysql database. I have create 2 scripts PHP and JavaScript. The PHP work, I have the good string in my variable $fin. But I don’t in using it in my JavaScript code. If someone can help me to fix my code, it will be great ! :mrgreen:
PHP :
<?php
//défintion paramètres connexion BDD
$bdd="localhost";
$login="root";
$bddname="essai";
//connexion à la BDD
$db=mysql_connect($bdd,$login);
//test conexion
if ( ! $db )
print("erreur");
//connecte à la base
mysql_select_db($bddname);
//requete BDD
$name="immeuble";
$table="essai_table";
$req="SELECT description FROM essai_table where nom='immeuble'";
$res=mysql_query($req,$db);
$row = mysql_fetch_row($res);
mysql_close($db);
//traitement
$fin=$row[0];
echo $fin;
/**
*
*
* @version $Id$
* @copyright 2013
*/
?>
JS :
//INFO BULLE
var afficher : boolean = false;
//récupération champ description
var res= "http://localhost/searchname.php?";
var description=WWW(res).text;
function OnGUI() {
//style label
var bulle=new GUIStyle();
bulle.normal.textColor=Color.red;
bulle.fontSize=15;
bulle.fontStyle= FontStyle.Bold;
bulle.border.right=1;
var bulle2=new GUIStyle();
bulle2.normal.textColor=Color.red;
bulle2.fontSize=15;
bulle2.fontStyle= FontStyle.Italic;
bulle2.border.right=1;
var info= "Immeuble" ;
var e : Event = Event.current;
if (afficher == true) {
GUI.Label (Rect (e.mousePosition.x+20, e.mousePosition.y+20, 300, 100), info, bulle );
GUI.Label (Rect (e.mousePosition.x+40, e.mousePosition.y+40, 300, 100), description, bulle2 );
}
}
function OnMouseOver () {
afficher = true;
}
function OnMouseExit () {
afficher = false;
}