Hi,
in first time, I want apologies me for English, I don’t speak English very well, I’m French.
My problem is, Flash application call a php script which make en xml file and Flash read this xml. But when I launch PHP from Flash, this not make xml but when he his launch in web browser it’s ok, the xml was created.
php :
<?php
if (isset ($_POST['req']))
{
include '../commun/fonctions.php';//appel du fichier de fonctions
$connexion = connect();
selectBase($connexion);
$requete = $_POST['req'];
//$requete = 'select idProjet, libProjet from PROJET;';
$ok=mysql_query($requete);
$ligne=mysql_fetch_assoc($ok);
//////fichier xml/////
if (mysql_num_rows($ok)!= 0)
{
$file= fopen("diapo.xml", "w");
$_xml ='<?xml version="1.0" encoding="UTF-8" ?>';
$_xml .="<general>";
while ($ligne)
{
$_xml .='<projet id="' . $ligne['idProjet'] . '" ';
$_xml .='libelle="' . $ligne['libProjet'] . '" />';
$ligne=mysql_fetch_assoc($ok);
}
$_xml .="</general>";
fwrite($file, $_xml);
fclose($file);
}
/////fin xml/////
$retour = "";
mysql_close($connexion);
}
else
{
$retour = 'Erreur lors de l\'envoi de la requete';
}
echo "&retour=".$retour;
?>
AS2 :
function executeReq(_reqEnvoye:String, _clip:Number):Void
{
var _env = new LoadVars();
// obj envoi
var _ret = new LoadVars();
// obj retour
_env.req = _reqEnvoye;
// on test si l'envoi a réussi
_ret.onLoad = function(success)
{
if (success){
var galleriexml:XML = new XML();
galleriexml.ignoreWhite=true;
galleriexml.onLoad = function(success) {
galleriev = galleriexml.firstChild.childNodes;
//Nombre d'images
var lon = galleriev.length;
//Pour chaque image à charger
//On recupere les données
galleriev = galleriexml.firstChild.childNodes;
//Nombre d'images
var lon = galleriev.length;
//Pour chaque image à charger
for (var i = 0; i<lon; i++) {
_tabId.push(galleriexml.firstChild.childNodes*.attributes.id);
_tabLib.push(galleriexml.firstChild.childNodes*.attributes.libelle);
}
menuProjet(_tabId,_tabLib);
};
galleriexml.load("diapo.xml");
}
else
{
retourPHP.text = "erreur de connexion à la base de données\r";
}
};
// on envoie la requete au script php
_env.sendAndLoad("reqProjet.php", _ret, "POST");
}
I used “sendAndLoad” because I dont know other function for make this.