close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

MySQLI Query Export to XML File

Thread began 5/20/2019 8:40 am by anonymous | Last modified 6/11/2019 8:20 am by anonymous | 1088 views | 9 replies

anonymous

Thank you for this. I am still getting this error message:

error on line 7 at column 6: XML declaration allowed only at the start of the document

Here is the code we have:

<?php require_once('Connections/sdpc_i.php'); ?>
<?php require_once('webassist/mysqli/rsobj.php'); ?>
<?php require_once('webassist/mysqli/queryobj.php'); ?>
<?php require_once('webassist/mysqli/authentication.php');
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL); ?>
<?php
if ("" == "") {
$RestrictAccess = new WA_MySQLi_Auth();
$RestrictAccess->Action = "restrict";
$RestrictAccess->Name = "sdpc_login";
$RestricAccessRedirect = "error.php";
if (function_exists("rel2abs")) $RestricAccessRedirect = $RestricAccessRedirect?rel2abs($RestricAccessRedirect,dirname(__FILE__)):"";
$RestrictAccess->FailRedirect = $RestricAccessRedirect;
$RestrictAccess->execute();
}?>
<?php
$query = new WA_MySQLi_RS("query",$sdpc_i,0);
$query->setQuery("SELECT * from ((SELECT agreement_typesID, agreement_name, state, description, category as thecategory, latest, public, concat('https://sdpc.a4l.org/agreements/',file_pdf) as agreement_file_pdf, concat('https://sdpc.a4l.org/agreements/',file_doc) as agreement_file_doc FROM agreement_types where state = ? and agreement_typesID = ? and category = ?) t1 left join (SELECT * FROM agreement_vendor_types) t8 on (t1.agreement_typesID = t8.agreement_typesID) left join (SELECT * from clause_agreement_type) t2 on (t1.agreement_typesID = t2.agreement_typesID or t2.agreement_type_vendorID = t8.agreement_type_vendorID) left join (SELECT * from contract_clauses) t3 on (t3.clauseID = t2.clauseID) left join (select * from clause_obligation) t4 on (t4.clause_agreement_typeID = t2.clause_agreement_typeID) left join (SELECT * from obligations) t5 on (t5.obligationID = t4.obligationID) left join (SELECT * from obligation_benchmark) t6 on (t4.clause_obligationID = t6.clause_obligationID) left join (SELECT *, benchmarkID as thebenchmarkID from benchmarks) t7 on (t6.benchmarkID = t7.benchmarkID))");
$query->bindParam("s", "".($_GET['state']) ."", "-1"); //state
$query->bindParam("i", "".($_GET['agreement_typesID']) ."", "-1"); //agreement_typesID
$query->bindParam("s", "".($_GET['category']) ."", "-1"); //category
$query->execute();
?>
<?php
function to_xml(SimpleXMLElement $object, array $row) {
foreach ($row as $key => $value) {
if (is_array($value)) {
$new_object = $object->addChild($key);
to_xml($new_object, $value);
} else {
// if the key is an integer, it needs text with it to actually work.
if ($key == (int) $key) {
$key = "$key";
}
$object->addChild($key, $value);
}
}
}
?>
<?php
ob_start();
while (!$query->atEnd()) {
$xml = new SimpleXMLElement('<data/>');
to_xml($xml, $query->Results[$query->Index]);
print $xml->asXML();
$query->moveNext();
}
$output = ob_get_contents();
ob_end_clean();
header('Content-Type: application/xml; charset=utf-8');
header('Content-Language: en');
header('Cache-Control: no-store, no-cache, must-revalidate');
header("Content-Length: ".strlen($output));
header("Date: ".gmdate('D, d M Y H:i:s T'));
echo($output);
?>

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...