473,396 Members | 1,853 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

problem in conversion of XML

118 100+
hi,

i run the below code i got the following error and also display output normal way instead of xml entries.plz help that what's the mistake in my code


[php]

<?
header("Content-type: text/xml");
$host = "localhost";
$user = "root";
$pass = "root";
$database = "DataMiningdb";

$linkID = mysql_connect($host, $user, $pass) or die("Could not connect to host.");
mysql_select_db($database, $linkID) or die("Could not find database.");

$query = "SELECT * FROM vehicles ORDER BY vehicle_id DESC";
$resultID = mysql_query($query, $linkID) or die("Data not found.");

$xml_output = "<?xml version=\"1.0\"?>\n";
$xml_output .= "<entries>\n";

for($x = 0 ; $x < mysql_num_rows($resultID) ; $x++){
$row = mysql_fetch_assoc($resultID);
$xml_output .= "\t<entry>\n";
$xml_output .= "\t\t<vehicle_id>" . $row['vehicle_id'] . "</vehicle_id>\n";
// Escaping illegal characters
$row['vehicle_make'] = str_replace("&", "&", $row['vehicle_make']);
$row['vehicle_make'] = str_replace("<", "<", $row['vehicle_make']);
$row['vehicle_make'] = str_replace(">", "&gt;", $row['vehicle_make']);
$row['vehicle_make'] = str_replace("\"", "&quot;", $row['vehicle_make']);
$xml_output .= "\t\t<vehicle_make>" . $row['vehicle_make'] . "</vehicle_make>\n";
$xml_output .= "\t</entry>\n";
}

$xml_output .= "</entries>";
echo $xml_output;

?>
[/php]

output:


Warning: Cannot modify header information - headers already sent by (output started at F:\Facebook\furniture11\Data Mining1\public_html\xmlparsing.php:1) in F:\Facebook\furniture11\Data Mining1\public_html\xmlparsing.php on line 2
5 Bayliner 5 Bayliner 5 Bayliner 4 Bayliner 4 Bayliner 4 Bayliner 3 Baja Marine 3 Baja Marine 3 Baja Marine 2 Miscellaneous 2 Miscellaneous 2 Miscellaneous 1 Miscellaneous 1 Miscellaneous 1 Miscellaneous
Jul 12 '08 #1
1 1138
pbmods
5,821 Expert 4TB
Heya, swethak.

Your script is outputting something before the header() call. Check for whitespace/newlines before your opening '<?' tag.
Jul 12 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

11
by: John | last post by:
Hello all, I am trying to read in lines into a buffer from a file. Normally I would do this very low-level, but I have come to the conclusion I must stop doing everything the hard way. So, I...
8
by: aravandor | last post by:
I'm a C++ beginner coming from Java and VB.Net I know that this is an elementary question, but I'm stumped. I'm trying to make a coordinate class to store 2 Dimensional points and a Rectangle...
7
by: john | last post by:
On my form i have a message box called txtItemDesc that displays the french phrase qualité Père Noël. Now then when i run this code on that text box: Dim chrArr() As Char chrArr =...
17
by: Jon Slaughter | last post by:
I'm having a little trouble understanding what the slicing problem is. In B.S.'s C++ PL3rdEd he says "Becayse the Employee copy functions do not know anything about Managers, only the Employee...
7
by: hierro | last post by:
I have a list of functions (all with suffix T). For each one, I need to implement the following: FunctionT() { if (some_condition) { // do some conversion first FunctionW(); // then do some...
0
by: Lokkju | last post by:
I am pretty much lost here - I am trying to create a managed c++ wrapper for this dll, so that I can use it from c#/vb.net, however, it does not conform to any standard style of coding I have seen....
0
by: VB Programmer | last post by:
Simple ASP.NET 1 site. Opened solution in beta 2 of 2.0. Ran thru conversion wizard and it states: "Conversion Complete. There were some errors during conversion." I view the conversion log...
16
by: Dany | last post by:
Our web service was working fine until we installed .net Framework 1.1 service pack 1. Uninstalling SP1 is not an option because our largest customer says service packs marked as "critical" by...
39
by: Martin Jørgensen | last post by:
Hi, I'm relatively new with C-programming and even though I've read about pointers and arrays many times, it's a topic that is a little confusing to me - at least at this moment: ---- 1)...
6
by: Blasting Cap | last post by:
I'm trying to convert a 1.1 app to 2.0, and keep finding one thing after another that either Framework 2.0 or Visual Studio 2005 doesn't like. Now this - In the global.asax, code that has been...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.