peanut2009
New Member
I have tried lot and can't locate the error please help with this code.While i run the code below it gives me following error:-Note that this code works good outside joomla framework.\[code\]XML Parsing Error: XML or text declaration not at start of entityLocation: http://50.116.97.120/~amarhost/storage/index.php/component/storage/?action=view_company&id=566Line Number 217, Column 1:<?xml version="1.0"?><?php JHTML::_('behavior.modal'); $app =& JFactory::getApplication(); $app->getCfg('sitename'); //outputs site name $host=$app->getCfg('host'); //outputs database host $user=$app->getCfg('user'); //outputs database user $db=$app->getCfg('db'); //outputs database name $pass=$app->getCfg('password'); $pre=$app->getCfg('dbprefix'); $dom = new DOMDocument("1.0"); $node = $dom->createElement("markers"); $parnode = $dom->appendChild($node); // Opens a connection to a MySQL server $connection=mysql_connect ($host, $user, $pass); if (!$connection) { die('Not connected : ' . mysql_error()); } // Set the active MySQL database $db_selected = mysql_select_db($db, $connection); if (!$db_selected) { die ('Can\'t use db : ' . mysql_error()); } // Select all the rows in the markers table $query = 'SELECT * FROM `'.$pre.'storage_companies_images` AS a INNER JOIN `'.$pre.'storage_companies` AS b ON b.user_id = a.company_name WHERE b.user_id='.$_REQUEST['id'].''; $result = mysql_query($query); if (!$result) { die('Invalid query: ' . mysql_error()); } $document =& JFactory::getDocument(); $document->setMimeEncoding( 'text/xml' ); while ($row = @mysql_fetch_assoc($result)){ $node = $dom->createElement("marker"); $newnode = $parnode->appendChild($node); $newnode->setAttribute("name", $row['storage_company']); $newnode->setAttribute("address", $row['address']); $newnode->setAttribute("lat", $row['latt']); $newnode->setAttribute("lng", $row['longi']); } $smd=$dom->saveXML(); echo $smd; ?> \[/code\]