Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Send an XML object or file to a PHP script

Posted on 2010-08-12
7
Medium Priority
?
447 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

This article discusses four methods for overlaying images in a container on a web page
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.
Suggested Courses

916 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