CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums
Results 1 to 2 of 2

Thread: PHP, XML and mySQL

  1. #1

    PHP, XML and mySQL

    I have the following code that i am not able to get media:content to work.

    PHP Code:

    ("Content-type: text/xml"); 

    $host "localhost"
    $user "user"
    $pass "IhaveThEanswer2012@!"
    $database "bbl_article"

    $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 links"
    $resultID mysql_query($query$linkID) or die("Data not found."); 

    $xml_output "<?xml version=\"1.0\" ?>\n"
    $xml_output .= "<channel>\n"
    $xml_output .= "\t\t<title>Ellucid Movies</title>\n"
    $xml_output .= "\t\t<link></link>\n"
    $x $x mysql_num_rows($resultID) ; $x++){ 
    $row mysql_fetch_assoc($resultID); 
    $xml_output .= "\t<item>\n"
    $xml_output .= "<title>" $row['name'] .".m4v" "</title>\n"
    $xml_output .= "<link>" $row['link'] . "</link>\n"
    $xml_output .= "<media:content url='" $row['local_link'] . ".m4v" "' type='video/mp4'/>\n";
    $xml_output .= "\t</item>\n"

    $xml_output .= "</channel>"


    What am I doing wrong.

    Also how can I do this in DOM?

    I was able to find this
    PHP Code:
    function createUserDetailsXml(array $result) {

    $dom  = new DOMDocument;
    $dom->formatOutput TRUE// enable automatic indenting
    $dom->loadXML('<users/>'); // set root node

    foreach($result as $row) {

    // create user-details node
    $user $dom->createElement('user-details');

    // create and append details to user-details node

    // add user-details node to XML document, e.g. users node
    $dom->saveXML(); // returns the formatted XML
    But can get it to work.

    Thanks for your help in advance.
    New to PHP and MySql. Started looking at scripts about a week ago. So far have very little understanding of it. So please be easy with me if I ask a stupid question.

  2. #2
    PeejAvery's Avatar
    PeejAvery is offline Super Moderator Power Poster
    Join Date
    May 2002

    Re: PHP, XML and mySQL

    For're iterating the database rows incorrectly.

    PHP Code:
    while ($row mysql_fetch_assoc($resultID)) {

    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

This is a survey!

HTML5 Development Center