xml show php sintax error on while loop


Joined
Jan 17, 2011
Messages
1
Reaction score
0
i hi keep getting this error
Parse error: syntax error, unexpected T_STRING in C:\xampp\htdocs on line 10

which is this line driving me crazey help me please
PHP:
$xmlBody .= "<?xml-stylesheet type="text/xsl" href="books06.xsl"?>";

i'm trying to create a while loop that queries from mysql database but its not working help please here's the full code

PHP:
<?php

header("Content-Type: text/xml"); //set the content type to xml
// Initialize the xmlOutput variable
$xmlBody = '<?xml version="1.0" encoding="ISO-8859-1"?>';
$xmlBody .= "<catalog>";
$xmlBody .= "<?xml-stylesheet type="text/xsl" href="books06.xsl"?>";


$xmlBody .= "

// Connect to your MySQL database whatever way you like to here
mysql_connect("localhost","root","") or die (mysql_error());
mysql_select_db("admin") or die ("no database");
// Execute the Query on the database to select items(20 in this example)
$sql = mysql_query("SELECT * FROM news ORDER BY news_date DESC LIMIT 0, 20");
while($row = mysql_fetch_array($sql)){
    // Set DB variables into local variables for easier use
    $news_id = $row["news_id"];
    $subject = $row["subject"];
    $news_date = strftime("%b %d, %Y", strtotime($row["news_date"]));
    $news_artical = $row["news_artical"];
    // Start filling the $xmlBody variable with looping content here inside the while loop
    // It will loop through 20 items from the database and render into XML format

    $xmlBody .= '
    <cd>

    <title>' . $news_id . '</title>
    <artist>' . $subject . '</artist>
   <country>' . $news_date . '</country>
   <company>' . $description . '</company>

        </cd>';
} // End while loop
mysql_close(); // close the mysql database connection
$xmlBody .= "</catalog>";
echo $xmlBody; // output the gallery data as XML file for flash
?>
 
Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top