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 Guestbook:(please 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:
<?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."
";
fclose($file);
?>
The XML file:
<?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:
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*.attributes.myName+"
";
myGuestbook.htmlText += "Email: "+this.firstChild.childNodes*.attributes.myEmail+"
";
myGuestbook.htmlText += "Website: "+this.firstChild.childNodes*.attributes.myURL+"
";
myGuestbook.htmlText += "Message: "+this.firstChild.childNodes*.firstChild.firstChild.nodeValue+"
";
myGuestbook.htmlText += "-----"+"
";
}
};
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