Solved

Send an XML object or file to a PHP script

Posted on 2010-08-12
7
438 Views
Last Modified: 2013-11-11
As simple as this sounds, for some reason I can't get my code to work.  What i am trying to do is have my flash program send an XML object or file to a PHP script to be read and logged into a MySQL database.  I know how to handle the MySQL, and I'd like to say that my PHP is fine too, but at this point I'm not certain.
/* Begin ActionScript 2.0 */

var input_xml = new XML()
input_xml.ignoreWhite = true
input_xml.contentType = "text/xml"

var xml = "http://j2imedia.com/kioskadmin/inc/layout.xml"
var php = "http://j2imedia.com/kioskadmin/inc/layout.php?user=" + user

save_button.onRelease = function(){
	trace(substring(master, 0, master.length - 1))
	input_xml.firstChild.firstChild.nodeValue = substring(master, 0, master.length - 1)
	input_xml.sendAndLoad(server_file, output_xml)
	//input_xml.send(php)
}

input_xml.onLoad = function(success){
	if(success){ trace(this.firstChild.firstChild.nodeValue) }
	else{ trace("Error loading input XML") }
}

/* End Actionscript 2.0 */

/* Start PHP */
<?php
	mysql_connect(localhost,"aquasius","launchme8804");
	mysql_select_db("Aquasius") or die("Unable to select database");
	
	$result = mysql_fetch_array(mysql_query('SELECT hash FROM users WHERE user = "' . $_GET['user'] . '"'));
	
	if($result[0] == $_GET['hash']){ $result = 'good'; }
	else{ $result = 'bad'; }

	echo '<?xml version="1.0"?>';
	echo "\t<list>";
	echo "\t\t<hash>" . $result . '</hash>';
	echo "\t</list>";
	echo '</xml>';
?>

Open in new window

0
Comment
Question by:nero777x
  • 4
  • 2
7 Comments
 
LVL 2

Expert Comment

by:badgerfoxfoxdeer
ID: 33425199
I'm not sure what your trying to do with your echo construct, just output the value to screen? there are issues with using echo like this (see http://php.net/manual/en/language.basic-syntax.php) maybe you need to use the asXML method?:

echo $xml->asXML();

You can also give it a filename

$xml->asXML('filename.xml');

let me know if this solves your problem or if you need more help

Cheers
0
 
LVL 34

Expert Comment

by:Beverley Portlock
ID: 33425221
Two things:

1) I hope that isn't your real database username and password - this is a PUBLIC forum

2) Are you urlencoding the XML in the flash before sending it? I don't know enough about actionscript to tell, but I cannot see anything that looks like encoding
0
 

Author Comment

by:nero777x
ID: 33426739
Sorry, I made a mistake.  I accidentally copied the wrong php file.  This is the correct file.  And no, the password is not my real password.
<?php
	mysql_connect(localhost,"aquasius","houseclear2401")
	mysql_select_db("Aquasius") or die("Unable to select database")

	$filename = 'layout.xml'
	$raw_xml = file_get_contents("php://input")

	print $raw_xml

	$fp = fopen($filename, "w")
	fwrite($fp, $raw_xml)
	fclose($fp)
?>

Open in new window

0
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 

Author Comment

by:nero777x
ID: 33428699
I need help fast, now.  This is a time sensitive project I'm working on.  So I hope raising the point cap will suffice.
0
 

Author Comment

by:nero777x
ID: 33429870
The input_xml.onLoad function doesn't seem to be in use ever.  When I push the button to create the XML, no traces come from that function.  A clue, perhaps?
0
 

Accepted Solution

by:
nero777x earned 0 total points
ID: 33432287
OK, problem fixed.  It turns out that I didn't have the semi-colons at the end of each line in the PHP file, as seen above.  Stupid mistake on my part, since I've been working with PHP for while now.
0
 
LVL 2

Expert Comment

by:badgerfoxfoxdeer
ID: 33435757
It's always the small things just glad you got it fixed, have you considered / have you a decent debugger? I use netbeans with xdebug think you can use it with eclipse too

Cheers
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I have found that much of my time doing support ends up being a constant repetition of the same steps to different people.  Early on I stated using web pages with Frequently Asked Questions (FAQs) to alleviate most of the burden.  Sometimes this jus…
The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
The goal of the tutorial is to teach the user how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question