SQL - PHP - XML - Flex 2
Howdy everyone!
I've only been playing with Flex for about 6 weeks or so and
I've figured out lots and lots from the online tutorials and help
system. However the project that I'm trying to put together
requires that I can pass data back and forth to Db's. I haven't
even tried to write into a database yet because for the last 3
weeks I've been trying every combination (except the working one's)
to write my Db data into XML and use an HTTPService tag to retrieve
it for use as dataProviders. I've tried everything remotely related
on this site. Several others I've found online and modified the
resultFormat and my variable types in every combination
(resultFormat = "[' ', Object, xml, e4x, text, array]" &
myDP:[ArrayCollection, Array, XML, XMLList, XMLListCollection]) and
have received as many errors & nonworking results for my
efforts. I'm not sure if perhaps there's a PHP/MySQL setting on my
server that's not set how it should be? or if I just have failed to
notice some simple detail.
Here's the PHP version I currently believe most promising:
quote:
<?php
require_once('Connections/peaceheartconnection.php');
header("Content-type: text/xml");
mysql_select_db($database_peaceheartconnection,
$peaceheartconnection);
$query_topics = "SELECT * FROM p_insight_topics";
$topics = mysql_query($query_topics, $peaceheartconnection)
or die(mysql_error());
$row_topics = mysql_fetch_assoc($topics);
$totalRows_topics = mysql_num_rows($topics);
mysql_select_db($database_peaceheartconnection,
$peaceheartconnection);
$query_categories = "SELECT * FROM p_insight_types";
$categories = mysql_query($query_categories,
$peaceheartconnection) or die(mysql_error());
$row_categories = mysql_fetch_assoc($categories);
$totalRows_categories = mysql_num_rows($categories);
print("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
$dataXML = '';
$dataXML .= "<data><categories>";
while($cat = mysql_fetch_object($categories))
$dataXML .= "<category>$cat->type</category>"
$dataXML .= "</categories>";
$dataXML .= "<topics>";
while($topic = mysql_fetch_object($topics))
$dataXML .="<topic>$topic->topic</topic>";
$dataXML .= "</topics></data>";
?>
<?php
echo $dataXML;
?>
<?php
mysql_free_result($topics);
mysql_free_result($categories);
?>
This gives me results that show up in the browser identical
to
An XML file from
"Flex 2 Training from the Source" (I event get the "no
associated style information ... document tree is shown" message
from Firefox).
Here are the relevant parts of the Flex app:
quote:
<mx:Application xmlns:mx="
http://www.adobe.com/2006/mxml"
xmlns:ns1="Components.*" layout="absolute" autoLayout="true"
horizontalScrollPolicy="off" verticalScrollPolicy="off"
creationComplete=" getData()" >
<!-- Service Definitions -->
<mx:HTTPService id="getTypesNTopics" url="../../data.xml"
method="POST" useProxy="false"
result="showData(event)" fault="handleFault(event);" />
<mx:HTTPService id="getTypesNTopics2"
url="../../topicsNcategories5.php" method="POST" useProxy="false"
result="showData2(event)" fault="handleFault2(event);" />
<!-- End Service Definitions-->
<mx:Script>
<![CDATA[
import mx.collections.XMLListCollection;
import mx.effects.*;
import mx.effects.easing.*;
import mx.containers.*;
import mx.core.*;
import mx.rpc.events.ResultEvent;
import mx.rpc.events.FaultEvent;
import mx.events.FlexEvent;
import mx.controls.Alert;
import flash.events.*;
import mx.managers.DragManager;
import mx.events.DragEvent;
import mx.collections.ArrayCollection;
import mx.rpc.events.ResultEvent;
import mx.rpc.events.FaultEvent;
[Bindable] private var topicsAC:ArrayCollection = new
ArrayCollection();
[Bindable] private var categoryAC:ArrayCollection = new
ArrayCollection();
[Bindable] private var topics2AC:XMLListCollection = new
XMLListCollection();
public function getData():void
getTypesNTopics.send();
getTypesNTopics2.send();
private function showData2(event:ResultEvent):void
//topics2AC = event.result.data.topics.topic;
lastResultValue2.text = "Event, Categories:"
+event.result.data.categories.category
+ "Event, Topics:" + event.result.data.topics.topic;
scrollMenu.dataProvider = event.result.data.topics.topic;
lastResultValue2.text = "Result: " +
String(event.result.data.topics.topic);
private function handleFault2(event:FaultEvent):void
lastResultValue2.text = "Error: " + event.fault;
(Keep in mind that the function & service tag contents
are just the latest version as of 20 mins ago.)
Any help would be greatly appreciated. There are still dozens
of other things I want to get working on but there's no point until
I can get my app. to talk with mySQL (databases). I'm begging
PLEASE after weeks of wasting time trying to get my <topic>
& <category> nodes to populate two ComboBoxes I just
wrote a static XML file last night--just so I could feel like I had
accomplished something (that's what the first Service tag does).
Thanks 2^65536 times!
Todd
As it is posted right now (resultFormat (rF) = default object
with the result assigned directly), I don't receive an error but
lastResultValue.text & scrollMenu (a comboBox) both read
"$topic->topic."
With rF = default (object) & topics2AC:ArrayCollection
(assigned to the text & CB) I get: "Type Coercion failed:
cannot convert "$topic->topic" to
mx.collections.ArrayCollection. ..."
With rF = e4x, data type (dT) = arrayCollection I get:
"Error: [RPC Fault faultString="Error #1088: The markup in the
document following the root element must be well-formed."
faultCode="Client.CouldNotDecode" faultDetail="null"] "
(e4x is the format that I WANT to use, but anything working
will suffice for now)
rF = xml, dT = AC: "Property data not found on
flash.xml.XMLDocument and there is no default value."
With the "xml version" tag removed rF = e4x, dT =
XMLListCollection I get " Error #1034: Type Coercion failed: cannot
convert "$topic->topic" to mx.collections.XMLListCollection."
Likewise with dT=arrayCollection: "Error #1034: Type Coercion
failed: cannot convert "$topic->topic" to
mx.collections.ArrayCollection." (Same with dT=XMLList)
The underlying code(source) of the PHP page's output is:
"<data><categories><category>Poem</category>
...</categories><topics><topic>Teaching</topic>...<topic>Kids</topic></topics></data>"
There's an empty line above the source. The <?xml version="1.0"
encoding="utf-8"?> tag is/isn't there depending on whether I
leave it in or not. I don't know how/why the empty line is there.
The general result seems to be that I get either "cannot
decode" using e4x, "cannot convert $topic->topic" using anything
else. Perhaps the problem is still in the PHP, but Firefox
recognizes & treats it as valid XML giving me the "
This XML file does not appear to have any style information
associated with it. The document tree is shown below.
−
<data>
−
<categories>
<category>Poem</category>
<category>Song</category>
<category>Prayer</category>
<category>Idea</category>
<category>Whim</category>
<category>Enlightenment</category>
<category>Quote</category>
<category>Answers</category> ..." when I call the
page. So I'm at a loss as to what to even try anymore.
Thanks again anyone, everyone
Merry Christmas, Happy Hannukah, Happy Holidays, etc.
Todd
Similar Messages
-
Issue with parameter passing in ie7 to php xml
Hi
I wondered if anyone could offer a little advice what the issue is here.
I have a page with xml generated from php in a separte file and presented by a dataset in spry.
The xml is OK and in firefox it all works but ie seems to barf on it.
The situation is this:
I have a jump menu on a front page that provides a url with anumeric parameter passed like this
platforms.php?platform_id=1
This parameter is picked up by php on the platforms.php page using the $_GET Array and is passed into the code in my Spry dataset to the file that runs my query and returns my xml- so basically the page displays a dataset filtered on this parameter id.
It works perfectly in FF.
In IE if I link straight to the page without a parameter at all- so platforms.php the page loads OK using the default parameter I have set up in the top of this page to send the default id of 1 to the code page so the spry query says platform_sql.php?platform_id=1 and the xml generator is fine with thisiel. ie I do a
if(isset($_GET['platform_id'])){
$platform=$_GET['platform_id'];
}else{
$platform=1;
The dataset loads Ok in IE but when I pass a parameter in the url from my jump menu IE gives a blank SPRY table i- it momentarily appears with just the placeholders for my dataset elements then vanishes. The source code of the page shows the correct id was set in the spry data going to my query file.
There is an error in ie saying there is a javascript error but its not any help- in ie fashion- FF shown no such errors.
I thought this might be a data type thing again in the dataset but its not - I have set the elements returned to simple strings but it still does not work.
Is there a problem passing in a parameter like this to a spry dataset?After about half a day of mucking round I found the problem and a solution to this problem.
What appeared to have happened was that some of the older content in my database used html originally encoded using a WYSWYG editor called ktml.
Later data uses Tiny MCE. It looks like the character set of the two formats is slightly different and as a result some characters rendered incorrectly when passed through XML parsing where it specifies the character set as utf-8.
Firefox on the whole seems to ignore the issue though looking at the raw xml output of my php-xml code- where "-" characters were (dashes) there was a question mark character shown. None the less in actual use on my page the xml was produced and the dataset worked out.
In IE, it barfed at these same characters and failed to return the xml dataset.
What confused the issue more was some of my smaller datasets if they by chance never had a "-" character in rendered OK in IE- hence my default dataset (platform_id=1) worked in IE. After much experimenting I noticed other ids worked too if there was never such a character.
How I got round it was to wrap my server side data in the utf8_encode() function, and now all my xml is clean.
The javascript error being thrown was a red herring though I could not tell until I managed to run my page in ie7 with Visual Studio Express error console running- I had this on a spare machine at work so could debug with it.
All sorted now- now just need to find away to wrap all my datasets in collapsible panels that work.
K -
Could we use embedded SQL for XML in .pc ?
Hi,
Can we use embedded SQL for XML in .pc ?
<1> assume we have run SQL statements in Oracle9i:
SQL>create table MY_XML_TABLE
(Key1 NUMBER,
Xml_Column SYS.XMLTYPE);
SQL>insert into MY_XML_TABLE(key1, Xml_Column) values
(1, SYS.XMLTYPE.CREATEXML
('<book>
<chapter num="1">
<text>This is the my text</text>
</chapter>
<book>')
<2> Could we directly translate it in .pc as usually:
<outlined, not exactly)
int emp_number = 1;
XML_Data emprec; /* ?????? */
EXEC SQL SELECT M.Xml_Column.GETCLOBVAL() as XML_Data
INTO :emprec INDICATOR :emprec_ind
FROM MY_XML_TABLE M
WHERE Key1 = :emp_number;
Thanks
MJreply by myself.
No problem!!
===============================
int emp_number = 1;
struct emprec{
char feature[1280]
EXEC SQL SELECT M.Xml_Column.GETCLOBVAL() as XML_Data
INTO :emprec INDICATOR :emprec_ind
FROM MY_XML_TABLE M
WHERE Key1 = :emp_number; -
I hope this is the right forum to post. I was wondering if there are any good tutorials or books on SQL to XML?
Basically I need to query accounts in the state of North Carolina that have recieved a certain document in the past day. That is a very easy task to do in SQL however the state of NC wants us to report our findings in a specific XML schema using nodes.
Luckily I have the schema which was given by the state of NC however not sure how to get my query to fit into the XML schema. Just wondering from a beginners perspective.
Sorry for the newbie questions.The [XML DB Forum|http://forums.oracle.com/forums/thread.jspa?threadID=410714&tstart=0] is a good place to start.
-
Import SQL Developer xml History files to a table
I'd like to import my SQL Developer xml history files into an Oracle table. What's the best way to do this?
I had some success in Pages 1, but I've only tried a couple of times so far in Pages 2 without success. The trick was to make sure the table is the exact number of columns wide. It's very "klunky" but I've ended up converting the tab-delimited text to a table in AppleWorks, saving the AppleWorks file with the table as a "floating" object (fixed objects don't translate) & opening the file in Pages. It's quicker & easier for most of what I do to just drag & drop in Pages.
Peggy -
Hi, Im very new to this and have a question: how do I transform sql to xml via xslt or jsp?
forexample:
DROP TABLE IF EXISTS bokbase;
CREATE TABLE bokbase (
bokID SMALLINT PRIMARY KEY AUTO_INCREMENT,
Regdato VARCHAR(15),
Writer VARCHAR(50),
Title VARCHAR(100),
Publisist VARCHAR(30),
place VARCHAR(30),
year VARCHAR(4),
Isbn VARCHAR(15),
about VARCHAR(20),
extra VARCHAR(255));
INSERT INTO bookbase VALUES ( 195,'1999.09.13','Gates,bill,'will it ever work?','microsoft','New York','1980','82-521-0989-6','something','');
thank you in advance.Try this SQL
select
xmlelement("BOKBASE",xmlelement("BOKID",bokID),xmlelement("REGDATO",regdato),xmlelement("WRITER",writer),
xmlelement("TITLE",title),xmlelement("PUBLISIST",publisist))
from bokbase -
Can someone please help me on basic info of PHP&XML&Flash
i want to go into displaying information from the MySQL
database into Flash Grid.... How can I do that and what tutorials
will guide me through to be able to that....?
AyoFor starters, read the Help Docs in Flash on Data
Integration. There's even a tutorial in Flash 8 called "Flash and
PHP Integration." Then you might want to Google "flash php xml
tutorial" which returns plenty of stuff to keep you reading for a
while.
Good luck! -
Explain about sql server XML
All related topic about XML in sql server
Hmm
Do you expect someone to write an essay for you?
Why not do some google search?
A simple search on SQL Server XML brings you lots of articles including these
http://technet.microsoft.com/en-us/library/ms189887(v=sql.105).aspx
https://www.simple-talk.com/sql/database-administration/manipulating-xml-data-in-sql-server/
https://www.simple-talk.com/sql/learn-sql-server/the-xml-methods-in-sql-server/
Please Mark This As Answer if it solved your issue
Please Mark This As Helpful if it helps to solve your issue
Visakh
My MSDN Page
My Personal Blog
My Facebook Page -
XDK for PL/SQL and XML Parser for PL/SQL
Is there a difference between the terms:
XDK for PL/SQL
and
XML Parser for PL/SQL V2
or are they the same thing...?
cheers,XDK stands for XML Developer's Kit. There are Oracle XDKs for Java, C, C++, and PL/SQL. These development kits contain building blocks for reading, manipulating, transforming, and viewing XML documents.
XML Parser is one component of XDK. Other components of XDK are
XSLT Processor, XSU, XSQL Servlet, XML Class Generator, etc.
For more information on XDK and its components please refer to:
http://otn.oracle.com/docs/products/oracle9i/doc_library/release2/appdev.920/a96621/adx01bas.htm#1656
Regards,
Anupama
http://otn.oracle.com/sample_code/content.html -
Processing ArrayCollection or XML in PHP from Flex
I know this is a Flex forum, but after I use HTTPService with
POST and an ArrayCollection or XML object as the parameter, anybody
have the PHP code I would use to grab the parameter on the server
side?
Once I have grabbed it and put it in a PHP variable I can
figure out the rest.
Thanks!One caveat for POST ing XML from AIR is that there is a bug
and it submits as GET instead. Work-around I had to use was to
upload XML file instead and then parse it.... otherwise from FLEX
If you POST the XML as a parameter like so
var params:Object = new Object()
params.postText = myXML
myHTTPService.send(params)
and your XML is something like.....
<root>
<record><data>mydata</data></record>
</root>
then the PHP script looks something like.........
foreach($_POST AS $key => $value) { ${$key} = $value; }
if(isset($postText)){
//echo $postText;
$xml = new SimpleXMLElement($postText, LIBXML_NOCDATA);
$record = $xml->record;
// use first record to capture column names into array
foreach($record[0]->record->children() as $col){
$colNames[] = $col->getName();
// then for each column , record get the values
foreach($record->record as $row){
foreach($colNames as $column){
$values[] = $row->$column;
//do something with the record
else{
exit;
//get record level element name;
$act = $xml->act;
$table = $xml->table;
$record = $xml->records;
// get column names -
Need Help with send raw xml to PHP from flex
Hello all,
I am trying to pass raw XML from flex to php.
I can pass the data using get but need to use POST.
When I submit the data via POST
the data is not available in $HTTP_RAW_POST_DATA.
Any help is greatly appreciattedHello all,
I am trying to pass raw XML from flex to php.
I can pass the data using get but need to use POST.
When I submit the data via POST
the data is not available in $HTTP_RAW_POST_DATA.
Any help is greatly appreciatted -
Flex + amfphp vs. flex +php&xml
Here's the deal. I hear how great amfphp is, and how much
easier it is to develop flex applications with a PHP back end by
using amfphp, but I don't understand it at all. On the other hand,
I DO understand how to use POST in Flex to make PHP mysql queries,
convert the results into xml and then use the xml in flex. It seems
SO straightforward and easy to understand compared with
understanding everything going on in amfphp, but I can see that it
will be a pain to do all the coding to get what I want done doing
it that way. So is it worth it to figure out amfphp and flex
remoting, or should I just churn out the code using what I know?
I want to do things the smart way, but I looked at a couple
amfphp tutorials and I have absolutely no clue what is going on. I
feel like I have wasted the whole night, and not learned anything,
while I could have been working on the code to do it with xml. The
explanations in those tutorials seem to assume a HUGE amount of
knowledge that I don't have, and I can't really find tutorials that
explain things in newbie language. Plus, I don't even know what
other tutorials I should look at and understand before I even start
to understand the amfphp tutorials, so I'm not sure the amount of
time its going to take for me to learn everything I need.
To top it all off, I don't really even get what the benefit
is... Look at the code below from one tutorial -
http://www.sephiroth.it/tutorials/flashPHP/flex_remoteobject/page003.php.
Aside from the fact that I barely understand what is going on, just
how is this easier than outputting xml?Maybe this will help explain...
http://blogs.adobe.com/mikepotter/2006/07/php_and_flex_js.html
Scott -
Dear Friends,
i am doing a ticker in Flex, i want to connect the xml
generated by php and fetch the data and display in data grid. iam
new to Flex. Kindly help me to do this assignment..
Thanks and Regards,
Syed Abdul RahimIn Flex Builder help take a look at HTTPService class. You
use this class to hit a URL on a server, and listen in the result
event for the data sent by the URL.
ATTA -
Using SQL view From SQL Express in Flex
Hello All , i am new at Flex and yet searching for a basic answere to even more basic question...
i am currently looking for a way o extract and import SQL views from my SQL Express database ( on my local host) and present it with RIA on desktop, grpahs Charts etc.
my question is, which way is the best to do so ?
need i to use Coldfusion For the Data ? and then Flex3 For the design ( i.e Graphs)?
or maybe using another ODBC program for XML file and then Connect it as Data Resource into the flex3 project
as you must see , i am a bit confused....
thanks in advanceHi,
If you go for AIR you can directly connect to Database and you can get the data and can be shown graphically ,
But if you Go for Webapplication(Flex ) then definately u should use some backend like CFC,PHP,JAVA,.Net............ in order to connect to DB and use Remote Objects/HttpService and show the Result Graphically.............. -
I am trying to load a XML file via SQL Loader. My loader file is as follows:
LOAD DATA
INFILE 'C:\Infile.xml' "str'</Record>'"
BADFILE 'C:\Infile.bad'
Replace
INTO TABLE Cust_Table
TRAILING NULLCOLS
dummy filler terminated by ">",
Month enclosed by "<Mo>" and "</M0>"
LOC_ID enclosed by "<LOC_ID>" and "</LOC_ID>",
LOC_DESC enclosed by "<LOC_DESC>"and "</LOC_DESC>",
Cust_ID enclosed by "<Cust_ID>" and "</Cust_ID>",
Cust_Name enclosed by "<Cust_Name>" and "</Cust_Name>" )
The problem I'm having is for some records the Cust_Id and Cust_Name is missing in the file. The error I'm getting when trying to load the file for those records is:
Rejected - Error on table Cust_Table, column Cust_Id.
Initial enclosure character not found
Not sure what I need to add to the loader file to resolve this error.
TIA,
ToddI would suggest u use External tables since its more flexible then
sqlloader & is a better option.
For using external tables
1)u will have to create a directory first
2)Generally creation od directory is done by sys,hence after creating the directory
privileges read & write to be provided to user .
3)Creation of external tables.
4) Now use the table as a normal table to insert ,update delete in
ur table.
U can get more information from
http://www.oracle-base.com/articles/9i/SQLNewFeatures9i.php#ExternalTables
Create Directory <directory_name> as <Directory path where file be present>
Grant read,write on directory <directory_name> to <username>
CREATE TABLE <table_name>
(<column names>)
ORGANIZATION EXTERNAL
TYPE ORACLE_LOADER
DEFAULT DIRECTORY ,directory_name>
ACCESS PARAMETERS
RECORDS DELIMITED BY NEWLINE
FIELDS TERMINATED BY ','
LOCATION (<filename>)
PARALLEL 5
REJECT LIMIT 200;
Hope this helps.
Maybe you are looking for
-
I bought my iPhone in December and it has worked well until today (3/15/15). Now, I cannot send or receive e-mail, access Yahoo Weather, or go online through Safari. I suspect that it is a Verizon problem. Any help?
-
HTTP_POST structure / syntax
Hello All, i have a requirement to connect to a web service which is not traditional, meaning when i try to make a proxy for it, it gives me a lot of headaches. Therefore, i am trying to use HTTP_POST, as i have found that there is a number of people
-
Photos Missing from Original's Show Package Content
Because I still have some photos with the ! over them when clicked, I decided to make a new library with the originals from the iPhoto Show Package Contents. I moved the existing library folder to the desktop and opened the library package with a con
-
I can't get a playlist on the Mac to my iPad
I created a playlist on the Mac but I cannot get it on my iPad. Any suggestions?
-
After leaving my Macbook Pro Retina 13" for a few seconds the mousepad is not responding (pointer on screen is not moving (freezing). The mousepad works again when touching after 15 - 20 seconds, howcome?