Display of improper array structure in cakephp

halt

New Member
I have a weird array result in which I got as a result from a stored procedure.Well, here's the array I have\[code\]array( (int) 0 => array( 't' => array( 'level' => '-5', 'longtitude' => '121.05123', 'latitude' => '14.62163', 'color' => '#000000' ) ), (int) 1 => array( 't' => array( 'level' => '-5', 'longtitude' => '121.051183333333', 'latitude' => '14.6216233333333', 'color' => '#000000' ) ),\[/code\]As you can see, it's kinda weird. Wherein it should be something like this\[code\]Array( [0] => Array ( [t] => Array ( [level] => -57 [longtitude] => 121.050321666667 [latitude] => 14.6215366666667 [color] => #040098 ) ) [1] => Array ( [t] => Array ( [level] => -61 [longtitude] => 121.050316666667 [latitude] => 14.621545 [color] => #040098 ) ) [2] => Array ( [t] => Array ( [level] => -63 [longtitude] => 121.050323333333 [latitude] => 14.62153 [color] => #040098 ) )\[/code\]Since i directly debug it after I got the results from the stored procedure, I really have no idea where to deal with this problem first.. By the way here's my controller which called the SP:\[code\] $this->loadModel('User'); $username = $this->Session->read('user'); $category = trim($_POST["category"]); $file_name = trim($_POST["file_name"]); $ssid = trim($_POST["ssid"]); $settings = trim($_POST["settings"]); $color_type = trim($_POST["color_type"]); App::import('Xml'); $this->header('Content-type:text/xml'); $this->layout=false; $query = "CALL GetSingleReportByCategory('$username','$file_name','$ssid','$category', '$settings','$color_type');"; $mydata = http://stackoverflow.com/questions/11499754/$this->User->query($query); debug($mydata);\[/code\]EDITI have noticed something. I have set my header as this:\[code\]$this->header('Content-type:text/xml');\[/code\]And yet as I debug my code using firebug, What I get in my Console under Headers tab, my Content-type is text/html. Where it's supposed to be text/xml. How am I going to enforce a text/xml content type for this?UPDATEI dunno if the following details in my Console in firebug under Headers tab would help me clarify my problem. \[code\]Response HeadersCache-Control no-store, no-cache, must-revalidate, post-check=0, pre-check=0Connection Keep-AliveContent-Length 187Content-Type text/htmlDate Mon, 16 Jul 2012 22:54:08 GMTExpires Thu, 19 Nov 1981 08:52:00 GMTKeep-Alive timeout=5, max=97Pragma no-cacheServer Apache/2.2.21 (Win32) mod_ssl/2.2.21 OpenSSL/1.0.0e PHP/5.3.8 mod_perl/2.0.4 Perl/v5.10.1X-Powered-By PHP/5.3.8Request HeadersAccept application/xml, text/xml, */*; q=0.01Accept-Encoding gzip, deflateAccept-Language en-us,en;q=0.5Connection keep-aliveContent-Length 100Content-Type application/x-www-form-urlencoded; charset=UTF-8Cookie CAKEPHP=u0p4dfh75ku6t19juokagts2u1Host 172.16.0.117Referer http://172.16.0.117/wifidrivescanportal/maps/mapUser-Agent Mozilla/5.0 (Windows NT 5.1; rv:12.0) Gecko/20100101 Firefox/12.0X-Requested-With XMLHttpRequest\[/code\]UPDATENow I get this error:\[code\]Warning (2): SimpleXMLElement::__construct() [simplexmlelement.--construct]: Entity: line 3: parser error : Extra content at the end of the document [CORE\Cake\Utility\Xml.php, line 178]Warning (2): SimpleXMLElement::__construct() [simplexmlelement.--construct]: <data><t><level>-5</level><longtitude>121.051183333333</longtitude><latitude>14. [CORE\Cake\Utility\Xml.php, line 178]Warning (2): SimpleXMLElement::__construct() [simplexmlelement.--construct]: ^ [CORE\Cake\Utility\Xml.php, line 178]\[/code\]On the second warning, if Im not mistaken, it was reading my xml values when it encountered something I have no idea of that it terminated my parsing. It should be latitude 14.2666668 and yet it was discontinued.
 
Back
Top