Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Send an XML object or file to a PHP script

Posted on 2010-08-12
7
Medium Priority
?
445 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

The last time I worked with Flash and Socket connections was in AS1. A recent project required flash connecting to a Socket, and sending receiving information - we figured it would be easy enough - we all know about the socket policy documents and c…
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
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…
The goal of the tutorial is to teach the user how to live broadcast using Flash Media Live Encoder and connecting it to YouTube to broadcast. Log into your Youtube account, choose live stream settings, start live stream from Flash Media Live Enc…

670 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