Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP: Strange behaviour while calling custom php functions
    primarykey
    data
    text
    <p>I am facing a strange behavior while coding in PHP with Flex. Let me explain the situation:</p> <p>I have two funcions lets say:</p> <p><strong>populateTable()</strong> //puts some data in a table made with flex <br/> <strong>createXML()</strong> //creates an xml file which is used by Fusion Charts to create a chart</p> <p>Now, if i call <strong>populateTable()</strong> alone, the table gets populated with data but if i call it with <strong>createXML()</strong>, the table doesn't get populated but <strong>createXML()</strong> does it's work i.e. creates an xml file.</p> <p>Even if i run following code, only xml file gets generated but table remains empty whereas i called populateTable() before createXML(). Any idea what may be going wrong?</p> <p>MXML Part</p> <pre><code>&lt;mx:HTTPService id="userRequest" url="request.php" method="POST" resultFormat="e4x"&gt; &lt;mx:request xmlns=""&gt; &lt;getResult&gt;send&lt;/getResult&gt; &lt;/mx:request&gt; </code></pre> <p>and</p> <pre><code>&lt;mx:DataGrid id="dgUserRequest" dataProvider="{userRequest.lastResult.user}" x="28.5" y="36" width="525" height="250" &gt; &lt;mx:columns&gt; &lt;mx:DataGridColumn headerText="No." dataField="no" /&gt; &lt;mx:DataGridColumn headerText="Name" dataField="name"/&gt; &lt;mx:DataGridColumn headerText="Age" dataField="age"/&gt; &lt;/mx:columns&gt; </code></pre> <p>PHP Part</p> <pre><code>&lt;?php //-------------------------------------------------------------------------- function initialize($username,$password,$database) //-------------------------------------------------------------------------- { # Connect to the database $link = mysql_connect("localhost", $username,$password); if (!$link) { die('Could not connected to the database : ' . mysql_error()); } # Select the database $db_selected = mysql_select_db($database, $link); if (!$db_selected) { die ('Could not select the DB : ' . mysql_error()); } // populateTable(); createXML(); # Close database connection } //-------------------------------------------------------------------------- populateTable() //-------------------------------------------------------------------------- { if($_POST['getResult'] == 'send') { $Result = mysql_query("SELECT * FROM session" ); $Return = "&lt;Users&gt;"; $no = 1; while ( $row = mysql_fetch_object( $Result ) ) { $Return .= "&lt;user&gt;&lt;no&gt;".$no."&lt;/no&gt;&lt;name&gt;".$row-&gt;name."&lt;/name&gt;&lt;age&gt;".$row-&gt;age."&lt;/age&gt;&lt;salary&gt;". $row-&gt;salary."&lt;/salary&gt;&lt;/session&gt;"; $no=$no+1; $Return .= "&lt;/Users&gt;"; mysql_free_result( $Result ); print ($Return); } //-------------------------------------------------------------------------- createXML() //-------------------------------------------------------------------------- { $users=array ( "0"=&gt;array("",0), "1"=&gt;array("Obama",0), "2"=&gt;array("Zardari",0), "3"=&gt;array("Imran Khan",0), "4"=&gt;array("Ahmadenijad",0) ); $selectedUsers=array(1,4); //this means only obama and ahmadenijad are selected and the xml file will contain info related to them only //Extracting salaries of selected users $size=count($users); for($i = 0; $i&lt;$size; $i++) { //initialize temp which will calculate total throughput for each protocol separately $salary = 0; $result = mysql_query("SELECT salary FROM userInfo where name='$users[$selectedUsers[$i]][0]'"); $row = mysql_fetch_array($result)) $salary = $row['salary']; } $users[$selectedUsers[$i]][1]=$salary; } //creating XML string $chartContent = "&lt;chart caption=\"Users Vs Salaries\" formatNumberScale=\"0\" pieSliceDepth=\"30\" startingAngle=\"125\"&gt;"; for($i=0;$i&lt;$size;$i++) { $chartContent .= "&lt;set label=\"".$users[$selectedUsers[$i]][0]."\" value=\"".$users[$selectedUsers[$i]][1]."\"/&gt;"; } $chartContent .= "&lt;styles&gt;" . "&lt;definition&gt;" . "&lt;style type=\"font\" name=\"CaptionFont\" size=\"16\" color=\"666666\"/&gt;" . "&lt;style type=\"font\" name=\"SubCaptionFont\" bold=\"0\"/&gt;" . "&lt;/definition&gt;" . "&lt;application&gt;" . "&lt;apply toObject=\"caption\" styles=\"CaptionFont\"/&gt;" . "&lt;apply toObject=\"SubCaption\" styles=\"SubCaptionFont\"/&gt;" . "&lt;/application&gt;" . "&lt;/styles&gt;" . "&lt;/chart&gt;"; $file_handle = fopen('ChartData.xml','w'); fwrite($file_handle,$chartContent); fclose($file_handle); } initialize("root","","hiddenpeak"); ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload