Visualizzazione dei risultati da 1 a 4 su 4

Discussione: mysql to xml

  1. #1

    mysql to xml

    ciao ragazzi
    da stamattina che sto facendo prove su i miei script in flash e xml. ho trovato su internet un tutorial che converte il contenuto delle tabelle mysql in xml ma il file xml che mi genera non è come quello che mi serve

    xml originale.

    - <rss>
    - <channel>
    - <item id="1">
    <title>capodanno</title>
    <pubDate>31/12/2007</pubDate>
    <image>images.jpg</image>
    <description>provaaaaaaaaaaaaaaaaaaaaaaaaaa</description>
    <link>http://www.salvodj.com</link>
    </item>
    </channel>
    </rss>

    script php.

    <?php
    header("Content-type: text/xml");

    $host = "localhost";
    $user = "root";
    $pass = "";
    $database = "gestione";

    $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 news ORDER BY id DESC";
    $resultID = mysql_query($query,$linkID) or die ("Data not found");

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

    for ($x = 0; $x < mysql_num_rows($resultID); $x++){
    $row = mysql_fetch_assoc($resultID);
    $xml_output .= "\t<channel>\n";
    $xml_output .= "\t<item id=\"" . $row['id'] . "\"/>";
    $xml_output .= "\t\t<title>" . $row['title'] . "</title>\n";
    $xml_output .= "\t\t<pubDate>" . $row['pubDate'] . "</pubDate>\n";
    $xml_output .= "\t\t<image>" . $row['image'] . "</image>\n";
    $xml_output .= "\t\t<description>" . $row['description'] . "</description>\n";
    $xml_output .= "\t\t<link>" . $row['link'] . "</link>\n";
    $xml_output .= "\t</channel>\n";
    }

    $xml_output.= "</rss>";

    echo $xml_output;
    ?>


    quello che mi esce da il php è questo.

    - <rss>
    - <channel>
    <item id="1" />
    <title>capodanno</title>
    <pubDate>31/12/2007</pubDate>
    <image>images.jpg</image>
    <description>provaaaaaaaaaaaaaaaaaaaaaaaaaa</description>
    <link>http://www.salvodj.com</link>
    </channel>
    </rss>


    ho provato e riprovato , ho fatto una ricerca anche su internet ma niente da fare
    magari se mi potete aiutare grazie.

  2. #2
    Utente di HTML.it L'avatar di and80
    Registrato dal
    Mar 2003
    Messaggi
    15,182
    è un problema di php più che di flash, comunque...

    manca una riga nel codice:

    Codice PHP:
    <?php
    header
    ("Content-type: text/xml");

    $host "localhost";
    $user "root";
    $pass "";
    $database "gestione";

    $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 news ORDER BY id DESC";
    $resultID mysql_query($query,$linkID) or die ("Data not found");

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

    for (
    $x 0$x mysql_num_rows($resultID); $x++){
    $row mysql_fetch_assoc($resultID);
    $xml_output .= "\t<channel>\n";
    $xml_output .= "\t<item id=\"" $row['id'] . "\"/>";
    $xml_output .= "\t\t<title>" $row['title'] . "</title>\n";
    $xml_output .= "\t\t<pubDate>" $row['pubDate'] . "</pubDate>\n";
    $xml_output .= "\t\t<image>" $row['image'] . "</image>\n";
    $xml_output .= "\t\t<description>" $row['description'] . "</description>\n";
    $xml_output .= "\t\t<link>" $row['link'] . "</link>\n";

    /* -> qui  -> */  $xml_output .= "\t</item>\n";

    $xml_output .= "\t</channel>\n";
    }

    $xml_output.= "</rss>";

    echo 
    $xml_output;
    ?>

  3. #3
    non và lo stesso!!

  4. #4
    Utente di HTML.it L'avatar di and80
    Registrato dal
    Mar 2003
    Messaggi
    15,182
    non ti da l'output che ti aspetti? cosa ti da?

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.