10-16-2004, 04:55 AM
|
#1
|
|
/(bb|[^b]{2})/
Join Date: May 2004
Location: Denver, CO
Posts: 2,740
|
Guestbook won't refresh entries on sendAndLoad
Howdy,
I can't figure out why this is not working and I have a headache now. I got a guestbook running off of my server and that works fine. The problem is that the entries won't refresh upon sending the data to the PHP file, they only refresh when I press the refresh button, except I don't want a refresh button. Because the entries are loading when you press the refresh button I'm guessing it's not a server problem, although my server has been a pain in the @ss lately  Anyway, here's my PHP script just in case you need it and the Guestbook linked to my server.
PHP Code:
<?php
$filename = 'lbguestbook.txt';
$date = (date ("m/d/y h:i A",time()));
$name = $_GET['Name'];
$email = $_GET['Email'];
$message = $_GET['Message'];
$combineEntries = "[/||/]Name: $name\nEmail: $email\nDate: $date\nMessage: $message";
$entries = stripslashes($combineEntries);
if (is_writable($filename)) {
if (!$file = fopen($filename, 'a')) {
exit;
}
if (fwrite($file, $entries) === FALSE) {
exit;
}
fclose($file);
}
?>
By the way, I'm not going to use this so I'm not going for looks, I was just too lazy to make it look good
Eric
Last edited by mmm..pi..3.14..; 10-16-2004 at 11:41 PM.
Reason: Removed the zip file...the fla was linked to my server
|
|
|
10-16-2004, 10:06 AM
|
#2
|
|
unRegistered User
Join Date: Aug 2004
Posts: 286
|
Ummm, you do know this is the Flash MX 2004 forum, right?
|
|
|
10-16-2004, 10:08 AM
|
#3
|
|
/(bb|[^b]{2})/
Join Date: May 2004
Location: Denver, CO
Posts: 2,740
|
Yes...why?? It's a flash mx 2004 file...
|
|
|
10-16-2004, 11:05 AM
|
#4
|
|
unRegistered User
Join Date: Aug 2004
Posts: 286
|
Hey, here's an updated version of your file. I was able to get it to load the data, but you have something in your PHP that grabs the "onLoad" function as well, and pastes it into the reply string, which causes it not to show up.
|
|
|
10-16-2004, 11:40 PM
|
#5
|
|
/(bb|[^b]{2})/
Join Date: May 2004
Location: Denver, CO
Posts: 2,740
|
Ok, I got it now
I put the sendAndLoad part of the script on top of the onLoad part which solved the problem of flash getting an "Error loading entries..." message and also solved the problem of flash sending the data to flash then trying to reload the new entries. The problem then was that it was sending the data so fast, flash wasn't sending the Message variable, only the Name and Email variables. I solved that by putting a setInterval around the sendAndLoad part for half a second. That delayed flash just long enough to send the message variable to the PHP script. Then the next problem was that the second after flash would send the data, flash would try to recieve the new data...much faster than the PHP script could write the entry to the text file. I then called upon my good buddy setInterval again and set the loading of the new entries to half a second...and voila! a working, pain in the @ss guestbook
Anyway, here's the script I used in case anybody was interested in it...
PHP Code:
function LoadEntries() {
_root.Entries.text = _root.Name.text=_root.Email.text=_root.Message.text="";
var newEntries:LoadVars = new LoadVars();
newEntries.onLoad = function(success) {
if (success) {
var gbArray:Array = this.gb.split("[/||/]").reverse();
for (var i = 0; i<gbArray.length; i++) {
_root.Entries.text += gbArray[i]+"\n\n";
}
}
};
newEntries.load("http://domain.com/bla/guestbook.txt?uniqueID="+getTimer());
}
LoadEntries();
//
//---------------------------------------------------
//
function Load() {
function waitToLoad() {
LoadEntries();
clearInterval(Wait);
}
Wait = setInterval(waitToLoad, 500);
}
//
//------------------------------------------------------
//
_root.Submit.onRelease = function() {
var gB:LoadVars = new LoadVars();
gB.Name = Name.text;
gB.Email = Email.text;
gB.Message = Message.text;
function SendData() {
clearInterval(waitTime);
gB.sendAndLoad("http://domain.com/bla/guestbook.php?uniqueID="+getTimer(), gB, "GET");
}
waitTime = setInterval(SendData, 500);
gB.onLoad = Load();
};
Thanks deQue,
Eric
|
|
|
10-17-2004, 10:18 AM
|
#6
|
|
unRegistered User
Join Date: Aug 2004
Posts: 286
|
Oh, on a side note, you DO know that when you send the message to the PHP code, it actually returns the new data to you? So you can skip the second sendAndLoad function, and just pull the new data from the object sending it the first time. Then you wont need all this by-passing.
|
|
|
10-17-2004, 11:01 AM
|
#7
|
|
/(bb|[^b]{2})/
Join Date: May 2004
Location: Denver, CO
Posts: 2,740
|
umm...yeah. But what the PHP script is doing is appending the new entry to the end of a text file, so the PHP script itself is not returning all the entries, what flash is doing is after it gets a response from the PHP file, flash reloads the TEXT file, which has the newest list of entries in it...
Eric
|
|
|
10-17-2004, 11:10 AM
|
#8
|
|
unRegistered User
Join Date: Aug 2004
Posts: 286
|
Yes, but from what I remember, it was returning the new data as well. Another thing you might want to think of, is in the future, when the list becomesd too long. You might need to modify the PHP script to clip the list into segments of 25 entries, so the loading will not take too long.
|
|
|
10-17-2004, 11:15 AM
|
#9
|
|
/(bb|[^b]{2})/
Join Date: May 2004
Location: Denver, CO
Posts: 2,740
|
I might do that, but as I said...I don't use this guestbook for my own use, I postt it on flashkit.com. I only modify the guestbook if I get an email from someone who downloaded it from flashkit saying that they would like to do something different...in that case, I make the changes and post it on flashkit.
Eric
|
|
|
| Thread Tools |
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT. The time now is 03:36 AM.
///
|
|