PHP/MySQL/XML Gives error -
my server.php file code below. error saying "this page contains following errors:
error on line 2 @ column 1: content @ end of document below rendering of page first error."
$server->register('restaurant'); // define method php function function restaurant($id) { $query = "select * `member_details` id=$id"; $result = mysql_query($query); if(!$result ) { die('could not data: ' . mysql_error()); } $xml_output = "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?> \n"; $xml_output .= "<?xml-stylesheet type=\"text/xsl\" href=\"xsltdetails.xsl\"?>"; $xml_output .= "<dataset>\n"; for($x = 0 ; $x < mysql_num_rows($result) ; $x++){ $row = mysql_fetch_assoc($result); $xml_output .= "<entry>\n"; $xml_output .= "<id>".$row['id']."</id>\n"; $xml_output .= "<name>".$row['name']."</name>\n"; $xml_output .= "<address>".$row['address']."</address>\n"; $xml_output .= "<postcode>".$row['postcode']."</postcode>\n"; $xml_output .= "<telephone>".$row['telephone']."</telephone>\n"; $xml_output .= "<opentime>".$row['opentime']."</opentime>\n"; $xml_output .= "<restauranttype>".$row['restype']."</restauranttype>\n"; $xml_output .= "<licence>".$row['licence']."</licence>\n"; $xml_output .= "<keywords>".$row['keywords']."</keywords>\n"; $xml_output .= "<cuisine>".$row['cuisine']."</cuisine>\n"; $xml_output .= "</entry>\n"; } $xml_output .= "</dataset>\n"; return $xml_output; } // use request (try to) invoke service $http_raw_post_data = isset($http_raw_post_data) ? $http_raw_post_data : ''; $server->service($http_raw_post_data); ?>
there must error in xml somewhere. please provide output can see more problem is. check if setting proper http headers header(). xml output, should be:
header( "content-type: text/xml" );
never use own code outputting xml when have many libraries @ disposal that. code less prone frustrating errors, cleaner , easier maintain. please see answer:
xml php "echo" getting error "extra content @ end of document"
on additional note, make sure not feeding unsanitized post data sql query. asking simple sql injection attack:
http://en.wikipedia.org/wiki/sql_injection
as in cases, there answers on stack overflow regarding issue well:
Comments
Post a Comment