Converting php to xml
Posted: Fri Jun 01, 2007 12:54 pm
Hi everyone ,
i have been trying to convert this code to an xml by using headers but this error keeps occuring
Warning: Cannot modify header information - headers already sent by (output started at /home/other/db2student/labdb224/public_html/xml1.php:1) in /home/other/db2student/labdb224/public_html/xml1.php on line 1
This is the code in php :
I would apreciate it if someone could help me ,
thanks in advance
i have been trying to convert this code to an xml by using headers but this error keeps occuring
Warning: Cannot modify header information - headers already sent by (output started at /home/other/db2student/labdb224/public_html/xml1.php:1) in /home/other/db2student/labdb224/public_html/xml1.php on line 1
This is the code in php :
Code: Select all
<?php header('Content-Type: text/xml');?>
<?php echo "<?xml version='1.0'?>"?>
<?php echo "<?xml-stylesheet type='text/xsl' href='xsl/projections.xsl'?>"?>
<projections>
<?php
$dbhost = "******";
$dbname = "*****";
$dbuser = "*****";
$dbpass = "*****";
mysql_connect ( $dbhost, $dbuser, $dbpass)or die("Could not connect: ".mysql_error());
mysql_select_db($dbname) or die(mysql_error());
$query="SELECT * FROM projections";
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
$i=0;
while ($i < $num) {
$movie=mysql_result($result,$i,"movie");
$room_number=mysql_result($result,$i,"room_number");
$start_time=mysql_result($result,$i,"start_time");
$end_time=mysql_result($result,$i,"end_time");
$date=mysql_result($result,$i,"date");
$projectionid=mysql_result($result,$i,"projectionid");
?>
<projection>
<titlos> <?php echo $movie; ?> </titlos>
<room_number> <?php echo $room_number; ?> </room_number>
<start_time> <?php echo $start_time; ?> </start_time>
<end_time> <?php echo $end_time; ?> </end_time>
<date> <?php echo $date; ?> </date>
</projection>
<?
$i++;
}
?>
</projections>thanks in advance