# Loading php and xml file

**URL:** <https://forum.kirupa.com/t/loading-php-and-xml-file/262102>\
**Category:** Uncategorized\
**Created:** [June 3, 2008, 10:40am UTC](https://forum.kirupa.com/t/loading-php-and-xml-file/262102 "2008-06-03T10:40:49Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![rollwithit80](https://avatars.discourse-cdn.com/v4/letter/r/ad7895/32.png) [@rollwithit80](https://forum.kirupa.com/u/rollwithit80)\
**Post date:** [June 3, 2008, 10:40am UTC](https://forum.kirupa.com/t/loading-php-and-xml-file/262102/1 "2008-06-03T10:40:49Z")

</div>

Hi Guys,  
I am trying to load a php that outputs xml data from a database. It then calls a function to display the thumbnails. For some reason I can’t get the php file to load. Can anyone help. I have ziped the file up. I have spent all day looking at the code and cant figure out why its not working. Thanks heaps

D

---

<div class="post-metadata">

**Author:** ![Pier25](https://avatars.discourse-cdn.com/v4/letter/p/4af34b/32.png) [@Pier25](https://forum.kirupa.com/u/Pier25)\
**Post date:** [June 3, 2008, 10:45am UTC](https://forum.kirupa.com/t/loading-php-and-xml-file/262102/2 "2008-06-03T10:45:57Z")

</div>

Are you enconding the xml in UTF8?

---

<div class="post-metadata">

**Author:** ![rollwithit80](https://avatars.discourse-cdn.com/v4/letter/r/ad7895/32.png) [@rollwithit80](https://forum.kirupa.com/u/rollwithit80)\
**Post date:** [June 3, 2008, 10:49am UTC](https://forum.kirupa.com/t/loading-php-and-xml-file/262102/3 "2008-06-03T10:49:31Z")

</div>

I’m not sure  
I’m including this in the xml output

\<?xml version=“1.0” ?\>

---

<div class="post-metadata">

**Author:** ![rollwithit80](https://avatars.discourse-cdn.com/v4/letter/r/ad7895/32.png) [@rollwithit80](https://forum.kirupa.com/u/rollwithit80)\
**Post date:** [June 3, 2008, 10:49pm UTC](https://forum.kirupa.com/t/loading-php-and-xml-file/262102/4 "2008-06-03T22:49:34Z")

</div>

Still didn’t fix it.  
Below is the code I am using:

```auto

Thumbs = function () {
    this. __init__ ();
    
    
};
Thumbs.prototype = new MovieClip ();
// **init class** //
Thumbs.prototype. __init__ = function () {
    this._xscale = 100
    this._yscale = 100
    //this._thumbs_.unloadMovie()
    this._dataProvider = new Array ();
    this._count = 0;
    this._depth = 1;
    this._isLoaded = -1;
    if (this._S_) {
        
        clearInterval (this._S_);
    }
    

    this._xmlfile='get_category_index.php';
    if (this._xmlfile != "") {
        this.loadPHPXML (this._xmlfile);
    }
    
};
Thumbs.prototype.loadPHPXML = function (x) {
    
    var _xml = new XML();
     _xml.ignoreWhite = true;
     _xml.path = this;
    _xml.load (x);
    _xml.onLoad = function () {

        trace(this.firstChild.childNodes.length);
        for (var i=0; i< this.firstChild.childNodes.length; i++) {
            var _categoryName = this.firstChild.childNodes*.attributes.catname;
            var _catID = this.firstChild.childNodes*.attributes.catid;
            var _img = this.firstChild.childNodes*.firstChild.nodeValue;
            
            this._dataProvider.push ({img:_img, categoryName:_categoryName, catID:_catID});
            
        };
        
        delete this;
    };
        this.selectThumbs();
        trace(this._dataProvider.length);
}

Thumbs.prototype.selectThumbs = function (first) { 

    trace(this._dataProvider.length);
    for (var i = 0; i<this._dataProvider.length; i++) {
        //for (var i = 0; i<3; i++) {
            
            // set variables - you can adjust gap and columns
            //this.thumbMC._alpha = 100;
            var name = i;
            var gap = 50;
            var columns = 3;
            var startx = 0;
            var starty = 0;
            var w = this.thumbMC._width;
            var h = this.thumbMC._height;
            var x = (i%columns)*(w+gap);
            var y = (Math.floor(i/columns))*(h+gap);
            // duplicate button
            this.thumbMC.duplicateMovieClip(name, i,this.getNextHighestDepth());
            // position button
            this[name]._x = x+startx;
            this[name]._y = y+starty;
            // load image
            this[name].imageMC.loadMovie("gallery/"+this._dataProvider*.img);
            
            
            // when clicked
            this[name].onRelease = function() {
                trace(image[this._name]);
                
                //Object.Main.containerMC.loadPic(image[this._name],theGallery, this.j);
                // this._alpha = 50;
            };
        
    };
    // hide the thumbMC (original)
    this.thumbMC._visible = false;
}

Thumbs.prototype.isLoaded = function (num) {
    this._isLoaded = num;
};
Object.registerClass ("Thumbs", Thumbs);

```

And below is the code in the php file

```auto

include("conf.php");
$qr = mysql_query("SELECT * FROM photo_category WHERE parentID=0",$server); echo mysql_error();
$nrows = mysql_num_rows($qr);
$nl = "
"; 
echo "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" . $nl; 
echo "<ROOT>".$nl; 
for ($i=0; $i < $nrows; $i++) {
    $row = mysql_fetch_array($qr);    
    
        echo "<imageUrl catname=\"".$row['name']."\" catid=\"".$row['ID']."\"><![CDATA[".$row['image_url']."]]></imageUrl>".$nl; 
}
echo "</ROOT>" . $nl; 

```

Thanks

Daniel

---

<div class="post-metadata">

**Author:** ![rollwithit80](https://avatars.discourse-cdn.com/v4/letter/r/ad7895/32.png) [@rollwithit80](https://forum.kirupa.com/u/rollwithit80)\
**Post date:** [June 6, 2008, 1:54pm UTC](https://forum.kirupa.com/t/loading-php-and-xml-file/262102/5 "2008-06-06T13:54:26Z")

</div>

Hey, I figured it out… thanks anyway.
