Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 10-16-2004, 04:55 AM   #1
mmm..pi..3.14..
/(bb|[^b]{2})/
 
mmm..pi..3.14..'s Avatar
 
Join Date: May 2004
Location: Denver, CO
Posts: 2,740
Unhappy 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
__________________
Eric Hainer
Unleaded Software
970.581.3387
Email: Eric followed by the AT symbol, unleaded software (one word) DOT com
Denver Web Design

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
mmm..pi..3.14.. is offline   Reply With Quote
Old 10-16-2004, 10:06 AM   #2
deQue
unRegistered User
 
deQue's Avatar
 
Join Date: Aug 2004
Posts: 286
Send a message via ICQ to deQue
Default

Ummm, you do know this is the Flash MX 2004 forum, right?
deQue is offline   Reply With Quote
Old 10-16-2004, 10:08 AM   #3
mmm..pi..3.14..
/(bb|[^b]{2})/
 
mmm..pi..3.14..'s Avatar
 
Join Date: May 2004
Location: Denver, CO
Posts: 2,740
Default

Yes...why?? It's a flash mx 2004 file...
__________________
Eric Hainer
Unleaded Software
970.581.3387
Email: Eric followed by the AT symbol, unleaded software (one word) DOT com
Denver Web Design
mmm..pi..3.14.. is offline   Reply With Quote
Old 10-16-2004, 11:05 AM   #4
deQue
unRegistered User
 
deQue's Avatar
 
Join Date: Aug 2004
Posts: 286
Send a message via ICQ to deQue
Default

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.
Attached Files
File Type: zip stupid guestbook.zip (289.1 KB, 302 views)
deQue is offline   Reply With Quote
Old 10-16-2004, 11:40 PM   #5
mmm..pi..3.14..
/(bb|[^b]{2})/
 
mmm..pi..3.14..'s Avatar
 
Join Date: May 2004
Location: Denver, CO
Posts: 2,740
Default

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 
0i<gbArray.lengthi++) {
                
_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(waitToLoad500);
}
//
//------------------------------------------------------
//
_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(SendData500);
    
gB.onLoad Load();
}; 
Thanks deQue,

Eric
__________________
Eric Hainer
Unleaded Software
970.581.3387
Email: Eric followed by the AT symbol, unleaded software (one word) DOT com
Denver Web Design
mmm..pi..3.14.. is offline   Reply With Quote
Old 10-17-2004, 10:18 AM   #6
deQue
unRegistered User
 
deQue's Avatar
 
Join Date: Aug 2004
Posts: 286
Send a message via ICQ to deQue
Default

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.
deQue is offline   Reply With Quote
Old 10-17-2004, 11:01 AM   #7
mmm..pi..3.14..
/(bb|[^b]{2})/
 
mmm..pi..3.14..'s Avatar
 
Join Date: May 2004
Location: Denver, CO
Posts: 2,740
Default

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
__________________
Eric Hainer
Unleaded Software
970.581.3387
Email: Eric followed by the AT symbol, unleaded software (one word) DOT com
Denver Web Design
mmm..pi..3.14.. is offline   Reply With Quote
Old 10-17-2004, 11:10 AM   #8
deQue
unRegistered User
 
deQue's Avatar
 
Join Date: Aug 2004
Posts: 286
Send a message via ICQ to deQue
Default

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.
deQue is offline   Reply With Quote
Old 10-17-2004, 11:15 AM   #9
mmm..pi..3.14..
/(bb|[^b]{2})/
 
mmm..pi..3.14..'s Avatar
 
Join Date: May 2004
Location: Denver, CO
Posts: 2,740
Default

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
__________________
Eric Hainer
Unleaded Software
970.581.3387
Email: Eric followed by the AT symbol, unleaded software (one word) DOT com
Denver Web Design
mmm..pi..3.14.. is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT. The time now is 02:19 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.