Error with my script

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • manjava
    New Member
    • Sep 2009
    • 132

    Error with my script

    hello,

    i have this code
    Code:
    <?php
    //ini_set('display_errors', true);
    ini_set('display_startup_errors', true);
    error_reporting(E_ALL);
     
    include_once 'connect.php';
     
    mysql_select_db($dbname, $conn);
     
    $sql = 'SELECT * FROM ule_1,ule_13,ule_75,ule_76,ule_77,ule_78,dule_79,ule_80,ule_81,ule_82';
    $qry = mysql_query($sql) or die(mysql_error());
     
    $xml = new DOMDocument('1.0', 'UTF-8');
     
    if (mysql_num_rows($qry))
    {
        $items = $xml->createElement('items');
     
        while ($data = mysql_fetch_assoc($qry))
        {
            $item = $xml->createElement('item');
            foreach ($data as $k => $v)
            {
                $node = $xml->createElement($k, $v);
                $item->appendChild($node);
            }
     
            $items->appendChild($item);
        }
     
        $xml->appendChild($items);
    }
     
    header('Content-type: text/xml');
    header('Charset: utf-8');
    echo $xml->saveXML();
    
    ?>
    when i execute it i have this error :Erreur d'analyse XML : aucun élément trouvé
    Emplacement : http://localhost/sqltoXML.php
    Numéro de ligne 2, Colonne 1 :
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    Please translate that error into English.

    Comment

    • manjava
      New Member
      • Sep 2009
      • 132

      #3
      XML Parsing Error: no element found
      Location: http://localhost/sqltoXML.php
      Line Number 2, Column 1

      Comment

      • Rabbit
        Recognized Expert MVP
        • Jan 2007
        • 12517

        #4
        Which line of code throws the error?

        I obviously couldn't use the query that you used but other than that, your code worked fine for me. I would check that the query is returning the data set as intended.

        Comment

        • manjava
          New Member
          • Sep 2009
          • 132

          #5
          Error: no element found
          Location: http://localhost/sqltoXML.php
          Line Number 2, Column 1

          thank in advance

          Comment

          • Rabbit
            Recognized Expert MVP
            • Jan 2007
            • 12517

            #6
            That must be talking about the XML data. I'm talking about the code. Because your code has no actual code on line 2.

            But like I said earlier, the crux of your code works fine for me. I get no errors. Did you inspect the item I asked you to inspect in my previous post?

            Comment

            • manjava
              New Member
              • Sep 2009
              • 132

              #7
              hello,

              it's not work for me.
              code on line 2.
              Code:
              ini_set('display_errors', true);
              thank you

              Comment

              • Rabbit
                Recognized Expert MVP
                • Jan 2007
                • 12517

                #8
                That's not line 2 of your code. Line 2 is:
                Code:
                //ini_set('display_errors', true);
                And it's commented out so it doesn't run.

                And like I already said, I get no errors from your non query code. The line number the error refers to is most likely about the XML, not the error in the code itself.

                Please inspect the element I asked you to look at two posts ago. I shouldn't have to ask you three times. And I shouldn't have to keep repeating myself like this.
                Last edited by Rabbit; Jul 3 '13, 09:30 PM.

                Comment

                • manjava
                  New Member
                  • Sep 2009
                  • 132

                  #9
                  hello,

                  how can i inspect the item, i don't know

                  Thanks in advance

                  Comment

                  • Rabbit
                    Recognized Expert MVP
                    • Jan 2007
                    • 12517

                    #10
                    By outputting the query string and it's results with echo.

                    Comment

                    • manjava
                      New Member
                      • Sep 2009
                      • 132

                      #11
                      hello,

                      anything on result so i want this result same of this
                      Code:
                      <?xml version="1.0" encoding="utf-8"?>
                      <message xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
                      <success />
                      <bookings hotelId="1245">
                      <booking id="EOC4440" action="Create" currency="EUR" date="2010-05-
                      14T10:03:25" totalAmount="256" paidAmount="200" dueAmount="56.0" origin="MySite.com"
                      paxCount="3">
                      <customer firstName="Alain" lastName="Dupont" title="Mr">
                      <contact email="alain.dupont@mail.com" phone="0620304050"
                      fax="0148002537">
                      <address city="Paris" country="FR"
                      postalCode="75002"><![CDATA[24 rue du sentier]]></address>
                      </contact>
                      <creditCard number="01234678912" cardHolder="Alain Dupont"
                      expiryDate="2009-03" cardType="Visa" />
                      <comment>
                      <![CDATA[Quiet room with balloons, please.]]>
                      </comment>
                      </customer>
                      <distributor>
                      <comment name="Cancel Policy">
                      <![CDATA[en cas de noshow, la première nuit sera
                      prélevée]]>
                      </comment>
                      <comment name="Guaranty">
                      <![CDATA[Credit Card guarantee]]>
                      </comment>
                      </distributor>
                      <rooms>

                      Comment

                      • Rabbit
                        Recognized Expert MVP
                        • Jan 2007
                        • 12517

                        #12
                        You've yet to respond appropriately or adequately to any of my posts. There's nothing I can help with until you do.

                        Comment

                        • manjava
                          New Member
                          • Sep 2009
                          • 132

                          #13
                          hello,

                          i tell you i do but i have any result

                          Thank you

                          Comment

                          • Rabbit
                            Recognized Expert MVP
                            • Jan 2007
                            • 12517

                            #14
                            hello,

                            i tell you i do but i have any result

                            Thank you
                            I have no idea what that is supposed to mean. You have done none of the stuff I have asked you to do.

                            Comment

                            Working...