jun lastmo
asked on
error on line 3 at column 1: Extra content at the end of the document - XML
<?php
include "config.php";
if( ! ini_get('date.timezone') ){
date_default_timezone_set('GMT');
}
/* require the user as the parameter */
if(isset($_GET['country'])) {
/* soak in the passed variable or set our own */
//$number_of_posts = isset($_GET['num']) ? intval($_GET['num']) : 10; //10 is the default
$format = strtolower($_GET['format']) == 'json' ? 'json' : 'xml'; //xml is the default
//$user_id = intval($_GET['user']); //no default
$country = $_GET['country'];
//$LastSyncDate = "2015-03-05 17:00:00.000";
/* connect to the db */
// $link = odbc_connect ('dms_production','sysprogress','sysprogress') or die('Cannot connect to ODBC data source.');
/* grab the posts from the db */
$query = "SELECT * FROM customers WHERE country='$country'";
$query = trim($query);
$result =mysqli_query($con,$query);
/* create one master array of the records */
$table = array();
if(mysqli_num_rows($result)) {
while($record = mysqli_fetch_array($result)) {
$table[] = array('record' => $record);
//echo array('record' => $record);
//query for reservation details
// $reservationdetails = "SELECT * FROM pub.sadtl WHERE id_sahdr = '".$record['id_sahdr']."'";
// $detailsresult = odbc_exec($link, TRIM($reservationdetails)) or die('Query error: '.TRIM($reservationdetails));
// if(odbc_num_rows($detailsresult)){
// while($res = odbc_fetch_array($detailsresult)){
// $table[] = array('record' => $record, 'details' => $res);
// }
}
}
/* output in necessary format */
if($format == 'json') {
header('Content-type: application/json');
//echo json_encode($table);
echo json_encode($table);
}
else {
header('Content-type: text/xml');
echo '<table>';
foreach($table as $index => $record) {
if(is_array($record)) {
foreach($record as $key => $value) {
echo '<',$key,'>'."aferfwefawfawefa";
if(is_array($value)) {
foreach($value as $tag => $val) {
echo '<',$tag,'>',htmlentities($val),'</',$tag,'>';
}
}
echo '</',$key,'>';
}
}
}
echo '</table>';
}
/* disconnect from the db */
@mysql_close($link);
}
else {
echo '<h3>Error: No passed parameters.<br>';
}
?>
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.