Everybody! This is important. In a few days, these forums will be moving over to using the totally sweet Discourse platform. To ensure this migration happens smoothly with no loss of content, these forums are currently in a read-only mode. I do apologize for the inconvenience.

There is never a good time to turn the forums off for an extended period of time, but I promise the new forums will be a billion times better. I'm pretty sure of it.

See you all on the other side in a few days, and if you have any (non-technical) questions, please e-mail me at kirupa@kirupa.com. For technical questions, try to find a tutorial that corresponds to what you are looking for and post in the comments section of that page.

Cheers,
Kirupa

Results 1 to 10 of 10

Thread: XML guestbook

  1. #1

    XML guestbook

    Hello people..

    I did the tutorial of
    the xml php guestbook here on the kirupa website..

    I changed it a bit and tested it on my own server and that worked fine.
    Now on the website it doesn't.. the guestbook.swf loads externally into a movieclip

    movieClip.loadMovie("guestbook.swf")

    I think that ain't a problem.
    But everytime i wan't to add a message it stops working and get the warning after a while that a flash script isn't working and if i want to end it.
    IS it because of the server from the new website?
    Is it because of XML? I changed the scripts both and i admit i'm not the best add it.
    Here is a link to the original tutorial:
    GuestBook tutorial

    And a link to the website and my Guestbookplease see both to see the difference with adding messages):
    Leo Moreno

    I put my new scripts with it so if someone can help me please do.
    I did not change the php and xml file:
    ThePHP file:
    HTML Code:
    <?php
    $file = fopen("guestbook.xml", "w+") or die("Can't open XML file");
    $xmlString = $HTTP_RAW_POST_DATA; 
    if(!fwrite($file, $xmlString)){
        print "Error writing to XML-file";
    }
    print $xmlString."\n";
    fclose($file);
    ?>
    The XML file:
    HTML Code:
    <?xml version="1.0"?><guestbook><entry myName="Leo Moreno" myURL="http://www.leomoreno.com" myEmail=""><myText>Welcome on my new website. Please leave a message. </myText></entry></guestbook>
    And my actionscripts:
    HTML Code:
    var currPage = 0;
    var showAmount = 10;
    // set this to the amount of entries you want to view at a time
    previous._visible = false;
    createMessage._visible = true;
    createButton.onRelease = function() {
    	this._visible = false;
    	this._parent.createMessage._visible = true;
    	if (createMessage.nameField.text == "") {
    		Selection.setFocus(createMessage.nameField);
    	} else if (createMessage.emailField.text == "") {
    		Selection.setFocus(createMessage.emailField);
    	} else if (createMessage.urlField.text == "http://") {
    		Selection.setFocus(createMessage.urlField);
    	} else if (createMessage.messageField.text == "") {
    		Selection.setFocus(createMessage.messageField);
    	}
    };
    // **** Load XML ****************************
    myXML = new XML();
    myXML.ignoreWhite = true;
    receiverXML = new XML();
    myXML.onLoad = function(success) {
    	myXML.contentType = "text/xml";
    	if (success) {
    		this.showXML();
    	} else {
    		trace("Error loading XML file");
    	}
    };
    myIdentifier = Math.round(Math.random()*10000);
    myXML.load("guestbook.xml?uniq="+myIdentifier);
    receiverXML.onLoad = function() {
    	this.contentType = "text/xml";
    	_root.currPage = 0;
    	this.showXML();
    };
    createMessage.sendButton.onRelease = function() {
    	var myName = this._parent.nameField.text;
    	var myEmail = this._parent.emailField.text;
    	var myURL = this._parent.urlField.text;
    	var myMessage = this._parent.messageField.text;
    	if (myName == "") {
    		this._parent.errorField.text = "Please fill out your name";
    		Selection.setFocus(this._parent.nameField);
    	} else if (myMessage == "") {
    		this._parent.errorField.text = "Please leave a message";
    		Selection.setFocus(this._parent.messageField);
    	} else {
    		myXML.firstChild.appendChild(myXML.createElement("entry"));
    		myXML.firstChild.lastChild.attributes.myName = myName;
    		myXML.firstChild.lastChild.attributes.myEmail = myEmail;
    		myXML.firstChild.lastChild.attributes.myURL = myURL;
    		myXML.firstChild.lastChild.appendChild(myXML.createElement("myText"));
    		myXML.firstChild.lastChild.lastChild.appendChild(myXML.createTextNode(myMessage));
    		myXML.sendAndLoad("processXML.php", receiverXML);
    		this._parent._visible = true;
    		createButton._visible = true;
    	}
    };
    XML.prototype.showXML = function() {
    	myGuestbook.scroll = 1;
    	myGuestbook.htmlText = "";
    	var numItems = this.firstChild.childNodes.length;
    	var firstItem = numItems-(currPage*showAmount);
    	if (currPage == 0) {
    		previous._visible = false;
    	}
    	var lastItem = firstItem-showAmount;
    	if (lastItem<=0) {
    		lastItem = 0;
    		next._visible = false;
    	}
    	myCount.text = "Total messages: "+numItems;
    	if (firstItem == lastItem+1) {
    		nowShowing.text = "Showing message "+firstItem;
    	} else {
    		nowShowing.text = "Showing message "+firstItem+" - "+(lastItem+1);
    	}
    	for (i=(firstItem-1); i>=lastItem; i--) {
    		myGuestbook.htmlText += "Name: "+this.firstChild.childNodes[i].attributes.myName+"\n";
    		myGuestbook.htmlText += "Email: "+this.firstChild.childNodes[i].attributes.myEmail+"\n";
    		myGuestbook.htmlText += "Website: "+this.firstChild.childNodes[i].attributes.myURL+"\n";
    		myGuestbook.htmlText += "Message: "+this.firstChild.childNodes[i].firstChild.firstChild.nodeValue+"\n\n";
    		myGuestbook.htmlText += "-----"+"\n\n";
    	}
    };
    previous.onRelease = function() {
    	currPage--;
    	myXML.showXML();
    	next._visible = true;
    };
    next.onRelease = function() {
    	currPage++;
    	myXML.showXML();
    	previous._visible = true;
    };
    stop();
    If someone will take the time to help me i'm very thankfull

    Kind regards Jos Koomen
    Hoorn, Netherlands

  2. #2
    I have a major problem with this as well..the same problem you have..try reposting this again

  3. #3
    i am bumping this thread..someone PLEASE help..i've posted in so many places..No one is helping..comon..

  4. #4
    Maybe we just must load the xml with a preloader because it is the problem of the from the xml guestbook.

  5. #5
    What's the file permission set to for guestbook.xml file???
    CyanBlue / Jason Je / Flash Developer
    http://CyanBlue.FlashVacuum.com
    http://www.FlashVacuum.com

  6. #6

    what do you mean?

    Quote Originally Posted by CyanBlue
    What's the file permission set to for guestbook.xml file???
    What do you mean with the permission how large it may be or so?

    MyDNA

  7. #7
    Hi! CyanBlue was talking about the permissions to read/write the XML file.

  8. #8
    Yeah, I think he means the file permissions as in read, write, and execute as group, owner, or public. (777) Try chmod the file permissions to 777 and see if that helps.

  9. #9
    Does anybody know how to write CDATA nodes into an xml from Flash using PHP ?

  10. #10
    msurgay... That sounds like a good topic to start a new thread rather than hijacking another thread...
    CyanBlue / Jason Je / Flash Developer
    http://CyanBlue.FlashVacuum.com
    http://www.FlashVacuum.com

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012