Hi,
OK, I know the question has been asked many times, but whatever I try, I can’t get it to work, and it’s starting to piss me off, so I decided to start (another) topic on this…
My swf contains a two dynamic textfields, wich get their data from a php file, which connects to a (utf8) MySql database. So far so good, and it’s working like it’s supposed to. I already succeeded in getting special characters into the text fields, which was quite a hassle, but it works now (System.useCodepage = true; helped a lot). I’ve also been trying with embedding fonts etc…
There’s only one annoying thing left: when there’s a ‘&’ sign in the text, the text breaks, because Flash thinks there’s another variable on its way. In the meanwhile I’ve read alot about this, and now I should utf_encode() the variables, and escape or unescape them in Flash. The problem is that I can’t get it to work. Here’s the php code I used at first:
$result = mysql_query("SELECT ID,project_name, project_loc FROM projects WHERE ID=3");
$cant = 0;
while($row=mysql_fetch_array($result)){
echo "ID$cant=$row[ID]&project_name$cant=$row[project_name]&project_loc$cant=$row[project_loc]&";
$cant++;
}
echo "cant=$cant";
and then I changed the echo line to this:
echo "ID$cant=$row[ID]&project_name$cant=utf8encode($row[project_name])&project_loc$cant=$row[project_loc]&";
But then utf8_encode( shows up, with the value from the DB next to it, so I’m probably not using utf_encode correctly. I’ve seen many examples of it, and tried several things, none of them worked yet…
And this is the actionscript I use in Flash:
myData = new LoadVars()
myData.load("http://www.myserver.com/data.php")
myData.ref = this
//Fetch data
myData.onLoad = function(succes){
if(succes){
for(var i=0; i<this.cant; i++){
this.ref["project_name_txt"+i].htmlText = "<b>"+this["project_name"+i]+"</b>"
this.ref["project_loc_txt"+i].text = this["project_loc"+i]
}
} else trace("Error loading data")
}
I tried unescaping and escaping like this:
unescape (this.ref["project_name_txt"+i].htmlText = "<b>"+this["project_name"+i]+"</b>")
but with no result…
So, anyone that can help me out with this ?
cheers
Jurgen