# Confirming data from PHP script

**URL:** <https://forum.kirupa.com/t/confirming-data-from-php-script/261331>\
**Category:** Uncategorized\
**Created:** [May 26, 2008, 2:35pm UTC](https://forum.kirupa.com/t/confirming-data-from-php-script/261331 "2008-05-26T14:35:44Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![activa](https://avatars.discourse-cdn.com/v4/letter/a/8491ac/32.png) [@activa](https://forum.kirupa.com/u/activa)\
**Post date:** [May 26, 2008, 2:35pm UTC](https://forum.kirupa.com/t/confirming-data-from-php-script/261331/1 "2008-05-26T14:35:44Z")

</div>

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:

```auto
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.

---

<div class="post-metadata">

**Author:** ![activa](https://avatars.discourse-cdn.com/v4/letter/a/8491ac/32.png) [@activa](https://forum.kirupa.com/u/activa)\
**Post date:** [May 26, 2008, 2:51pm UTC](https://forum.kirupa.com/t/confirming-data-from-php-script/261331/2 "2008-05-26T14:51:37Z")

</div>

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  
” it returns true. Where is this new line getting appended, and how can I avoid it?

---

<div class="post-metadata">

**Author:** ![Mugless](https://avatars.discourse-cdn.com/v4/letter/m/c77e96/32.png) [@Mugless](https://forum.kirupa.com/u/Mugless)\
**Post date:** [May 29, 2008, 2:17am UTC](https://forum.kirupa.com/t/confirming-data-from-php-script/261331/3 "2008-05-29T02:17:05Z")

</div>

You’ve probably already tried the obvious to see that it’s not coming from  
your PHP output:

```auto
echo rtrim($myOutputToFlash);

```

---

<div class="post-metadata">

**Author:** ![sekasi](https://avatars.discourse-cdn.com/v4/letter/s/5f8ce5/32.png) [@sekasi](https://forum.kirupa.com/u/sekasi)\
**Post date:** [May 29, 2008, 3:11am UTC](https://forum.kirupa.com/t/confirming-data-from-php-script/261331/4 "2008-05-29T03:11:43Z")

</div>

try both of these;

String(event.target.data) == ‘secretString’

event.target.data.toString() == ‘secretString’
