PDA

View Full Version : confirming data from PHP script



activa
May 26th, 2008, 11:35 AM
I have a swf that sends data to a PHP script on my server. The script works fine, sends me an email, and sends a string back to the swf. The swf sees the data, but is behaving strangely. Here's what I mean:


function onComplete (event:Event) {
if (event.target != null) {
if (event.target.data == 'secretString') {
trace ('ok');
} else {
trace (event.target.data);
}
}
}

The PHP script sends the correct string. I know because the swf traces 'secretString.' Why doesn't it recognize the string in the if conditional? I've already checked the dataFormat, and it confirms that the data is text.

activa
May 26th, 2008, 11:51 AM
I discovered the problem--the string returned by the PHP script has a new line appended to it, so if I test for "event.target.data == 'secretString\n" it returns true. Where is this new line getting appended, and how can I avoid it?

Mugless
May 28th, 2008, 11:17 PM
You've probably already tried the obvious to see that it's not coming from
your PHP output:


echo rtrim($myOutputToFlash);

sekasi
May 29th, 2008, 12:11 AM
try both of these;

String(event.target.data) == 'secretString'

event.target.data.toString() == 'secretString'