Welcome, Guest. Please login or register.
Did you miss your activation email?
05/22/12, 07:26
Home Help Search Login Register
News: Parsley Flex framework review featuring quiz application, in our Flex frameworks series
Flex SDK 4.5 mobile roadmap: begin with your mobile development
Swiz Flex framework review featuring quiz application
New homepage we release our new Homepage, take a look ...

+  Flash-db
|-+  Server side Scripting and Database Support
| |-+  MySQL, PostgreSQL, MS SQL, Access (Moderators: Flash-db, Musicman, Ronald Wernecke, Jorge Solis, Andries Seutens)
| | |-+  Not showing Guest Entries or Total Entries
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] Print
Author Topic: Not showing Guest Entries or Total Entries  (Read 3346 times)
Redneckheaven
Server what's that
*
Posts: 9


View Profile
« on: 11/18/09, 15:45 »

Hello I am using the php for the guestbook. I got everything working but doesnt post to book of my table.

Here is the code I am using:

Code:


<?
/*
-----
Application: Flash-dB GuestBook Version 2.0
Details:     mySQL and PHP powered GuestBook
Author:      Mohsin Sumar
Website:     http://www.flash-db.com
Support:     http://www.flash-db.com/Board
Notes:       Coments are marked by using comment entries symbols. Eg: // Comment
-----
*/

// Part One - Initiate a mySQL Database Connection
// Database Connectivity Variables and other Variables
   $DBhost = "Localhost";   // Database Server
   $DBuser = "**********";            // Database User
   $DBpass = "*********";            // Database Pass
   $DBName = "My Database Name";            // Database Name
   $table = "My Database Name.guestbook";             // Database Table
   $numComments = 20;       // Number of Comments per page
  
   // Connect to mySQL Server
   $DBConn = mysql_connect($DBhost,$DBuser,$DBpass) or die("Error in GuestBook Application: " . mysql_error());
   // Select mySQL Database
   mysql_select_db($DBName, $DBConn) or die("Error in GuestBook Application: " . mysql_error());

// Part Two - Choose what action to perform
   $action = $_GET['action'];
  
   switch($action) {
      case 'read' :
// Fetch all comments from database table
$sql = 'SELECT * FROM `' . $table . '`';
$allComments = mysql_query($sql, $DBConn) or die("Error in GuestBook Application: " . mysql_error());
$numallComments = mysql_num_rows($allComments);
// Fetch page-wise comments from database table
$sql .= ' ORDER BY `time` DESC LIMIT ' . $_GET['NumLow'] . ', ' . $numComments;
$fewComments = mysql_query($sql, $DBConn) or die("Error in GuestBook Application: " . mysql_error());
$numfewComments = mysql_num_rows($fewComments);
// Generate Output for Flash to Read
print '&totalEntries=' . $numallComments . '&';
print "<br>&entries=";

if($numallComments == 0) {
   print "No entries in the guestbook, as yet..";
} else {
   while ($array = mysql_fetch_array($fewComments)) {
  $name = mysql_result($fewComments, $i, 'Name');
  $email = mysql_result($fewComments, $i, 'Email');
                           $website = mysql_result($fewComments, $i, 'Website');
                           $state = mysql_result($fewComments, $i, 'State');
  $comments = mysql_result($fewComments, $i, 'Comments');
  $time = mysql_result($fewComments, $i, 'time');
 
   print '<b>Name: </b>' . $name . '<br><b>Email: </b>' . $email . '<br><b>Website: </b>' . $website . '<br><b>State: </b>' . $state . '<br><b>Comments: </b>' . $comments . '<br><i>Date: ' . $time . '</i><br><br>';
  $i++;
   }
}
// Print this only when there aren't any more entries..
if($_GET['NumLow'] > $numallComments) {
  print 'No More Entries!&';
}
break;

 case 'write' :
    // Recieve Variables From Flash
$name = ereg_replace("&", "%26", $_POST['yourname']);
$email = ereg_replace("&", "%26", $_POST['youremail']);
                 $website = ereg_replace("&", "%26", $_POST['yourwebsite']);
                 $state = ereg_replace("&", "%26", $_POST['yourstate']);
$comments = ereg_replace("&", "%26", $_POST['yourcomments']);
$submit = $_POST['submit'];

// Current system date in yyyy-mm-dd format
$submitted_on = date ("Y-m-d H:i:s",time());

// Check if its submitted from Flash
if($submit == 'Yes'){
// Insert the data into the mysql table
$sql = 'INSERT INTO ' . $table .
                ' (`ID`,
  `Name`,
  `Email`,
                                   `Website`,
                                   `State`,
  `Comments`,
  `time`
 )
 VALUES
 (\'\','
  . '\'' . $name . '\','
  . '\'' . $email . '\','
                                   . '\'' . $website . '\','
                                   . '\'' . $state . '\','
  . '\'' . $comments . '\','
  . '\'' . $submitted_on . '\'
  )';
$insert = mysql_query($sql, $DBConn) or die("Error in GuestBook Application: " . mysql_error());

// If you want your script to send email to both you and the guest, uncomment the following lines of code
// Email Script Begin

/* <-- Remove this line
$MyName = "";
$MyEmail = "mohsinsumar@hotmail.com";
$Subject = "$name has just signed your guestbook.";
$EmailBody = "Hello ,\n$name has just signed your guestbook available at http://www.redneckheaven.net. THe following were the details submitted into your guestbook:\n\nName: $name\nEmail: $email\nComment:\n$comments\n";

$EmailFooter = "~~~~~~~~~~~~~~~\nThe guestbook was signed by $name and thus this email got activated by $name from $REMOTE_ADDR from http://www.\n~~~~~~~~~~~~~~~\nThanking you,\n";

$Message = $EmailBody.$EmailFooter;

mail($MyName." <".$MyEmail.">",$Subject, $Message, "From: ".$name." <".$email.">");
--> Remove this line */

// Email Script End

print "&error=Thank you for signing my guestbook.&done=yes&";
return;
}
print "&write.error=Error!&";
break;
   }
?>


Not sure why this isnt putting the info in the table and then printing the entries.
« Last Edit: 11/19/09, 00:05 by Redneckheaven » Logged
Redneckheaven
Server what's that
*
Posts: 9


View Profile
« Reply #1 on: 11/18/09, 21:03 »

Ok i am now able to get info posted in my database table, but having problems with info, comments and totalEntries to the guestbook.  My Var for the area where entries are to be posted is registery and Var for totalEntries is entries. Some where in the code either php or the submit button is wrong. Can someone please lend a helping hand.

                             Thanks
                                           Kevin
Logged
Redneckheaven
Server what's that
*
Posts: 9


View Profile
« Reply #2 on: 11/19/09, 00:04 »

Getting very frustrating   Undecided . Have tried all kinds of things for hours and cant seem to get entries and totalEntries to appear. Only thing that shows up is in the entries area which I have as registery, is Loading entries... Please wait... and nothing in the totalEntries box which is called entries. Bound to be someone that knows why this is happening.
Logged
Ronald Wernecke
Administrator
Systems Administrator
*****
Posts: 6175


View Profile WWW Email
« Reply #3 on: 11/19/09, 18:00 »

if you post a life link, we can have a look.
Logged

happy flashing
Cool
Ronald
Redneckheaven
Server what's that
*
Posts: 9


View Profile
« Reply #4 on: 11/20/09, 00:27 »

I dont have site completely done. Am working on guestbook, contact form and other things. What I do is upload all files to my server/host and label the guestbook as index so when I go to my site the guestbook shows. Not sure what would be the easiest thing to do. If you can suggest a time when you can look at it i can make it available to go to. My web addy is www.redneckheaven.net   Please let me know.

                                                          Kevin
Logged
Ronald Wernecke
Administrator
Systems Administrator
*****
Posts: 6175


View Profile WWW Email
« Reply #5 on: 11/20/09, 04:22 »

somehow communication between your flash frontend and server backend does not work propperly.

You can download charles from www.charlesproxy.com/download to finout how communication is running, and if there are error messages.
Logged

happy flashing
Cool
Ronald
Redneckheaven
Server what's that
*
Posts: 9


View Profile
« Reply #6 on: 11/20/09, 09:37 »

Downloaded Charles. Made guestbook live. Tried to sumbit info, info set to table but Didnrt write to guestbook. Also now errors found in Charles. Here is the report;

Host   http://www.redneckheaven.net
Path   /
Notes   
Requests   2
Completed   2
Incomplete   0
Failed   0
Timing   
Start   11/20/09 9:29:30 AM
End   11/20/09 9:29:30 AM
Duration   297 ms
Requests / sec   6.73
Durations   250 ms
Latency   140 ms
Speed   7.32 KB/s
Request Speed   11.46 KB/s
Response Speed   29.24 KB/s
Size   
Requests   915 bytes
Responses   958 bytes
Combined   1.83 KB
Compression   

Some where it has to be in the php file telling it where to write. Pretty new at php so must be something easy I missed.
Logged
Ronald Wernecke
Administrator
Systems Administrator
*****
Posts: 6175


View Profile WWW Email
« Reply #7 on: 11/20/09, 09:46 »

Don't put so much guesswork into it Wink

What exactly does charles say in the response window?

You said: you put it life - where?

Your homepage link is a commercial site of your registrar.
Logged

happy flashing
Cool
Ronald
Redneckheaven
Server what's that
*
Posts: 9


View Profile
« Reply #8 on: 11/20/09, 10:11 »

Yes when you go to www.redneckheaven.net it goes to registration page, what I do is rename that php file to index2.php and name my guestbook file to index.html. Then i go to www.redneckheaven.net the guestbook comes up. I dont leave the guestbook live while I am working on it. Tell ya what I will make in where u can go to www.redneckheaven.net and the guestbook will appear then u can take a look. I will run Charles again and let you know.
Logged
Redneckheaven
Server what's that
*
Posts: 9


View Profile
« Reply #9 on: 11/20/09, 10:18 »

Ok it should be live at www.redneckheaven.net. The button to scroll the guestbook entries arent working havent put code on them yet. Everything else should be.
Logged
Ronald Wernecke
Administrator
Systems Administrator
*****
Posts: 6175


View Profile WWW Email
« Reply #10 on: 11/20/09, 12:45 »

ok so far.
Serverside works as expected.
It looks like a path issue on the flash side.

The data is sent by the server - you only have to fetch the received data, and assign it to the textbox.
Logged

happy flashing
Cool
Ronald
Redneckheaven
Server what's that
*
Posts: 9


View Profile
« Reply #11 on: 11/20/09, 13:05 »

Ok here is what I have on sumit button, just from error = and below the rest is just the validation or text areas filled in;

error = "Please wait...";
       
        newEntry = new LoadVars()
        newEntry.ref = this
        newEntry.submit = "Yes"
        newEntry.yourname = yourname
        newEntry.youremail = youremail
        newEntry.yourwebsite = yourwebsite
        newEntry.yourstate = yourstate
        newEntry.yourcomments = yourcomments
        newEntry.sendAndLoad("GuestBook.php?action=write&r="+random(999), newEntry, "POST")
        newEntry.onLoad = function(success){
            if(success){
                error = this.error;
                _root.read.loadEntries("Default", 20);
                // Clear fields
                yourname = "";
                youremail = "";
                yourwebsite = "";
                yourstate = "";
                yourcomments = "";
                capinput = "";
               
                L1.gotoAndPlay(1);
                L2.gotoAndPlay(1);
                L3.gotoAndPlay(1);
                L4.gotoAndPlay(1);
                L5.gotoAndPlay(1);
                L6.gotoAndPlay(1);
               
                gotoAndPlay(2);
            }
        }
    }
}

Now the code on the read Movie Clip:

function loadEntries(act, increment) {
   
    // Define NumLow as a Number
    num = new Number(NumLow);
   
    // Act accordingly
    if(act == "Next") {
       
        // Add increment
        NumLow = num + increment;
    } else if(act == "Previous") {
        NumLow = num - increment;
    } else {
       
        // Load default - i.e. 0
        NumLow = 0;
    }
   
    // Update Statistics
        NumLow = NumLow;
        NumHigh = Number(NumLow) + 20;
   
    // Show Please wait text
    entries = "Loading entries... Please wait...";
   
    // Begin Loading
    myEntries = new LoadVars()
    myEntries.ref = this
    myEntries.load("GuestBook.php?action=read&r="+random(999)+"&NumLow="+NumLow)
    myEntries.onLoad = function(success){
        if(success){
           
            // Assign output to components and objects
            entries = this.entries;
            totalEntries = this.totalEntries;
           
             loadEntries("Default", 20);

    stop();
        }
    }
}


Where it says entries = this.entries    entries is where the info is to be loaded and have its Var as enteries
Where it says totalEntries = this.totalEntries is for the total of entries in the guestbook and its VAR is totalEntries


Logged
Ronald Wernecke
Administrator
Systems Administrator
*****
Posts: 6175


View Profile WWW Email
« Reply #12 on: 11/21/09, 00:54 »

Hi,
you have this remark

// Assign output to components and objects

but I dont see you assigning the results to the fields

- best to start your revision: look at the original and compare the differences to your version.
Logged

happy flashing
Cool
Ronald
Redneckheaven
Server what's that
*
Posts: 9


View Profile
« Reply #13 on: 11/21/09, 01:09 »

That is from the original. Only thing I did was change the look, added captcha and not using the _visiable = true statement. I built the guestbook, gave my textfields, textbox, totalEntries, etc the same Var name. Also have 2 movie clips just like the original but not using _parent,_parent. Onlything that doesnt work is the posting of the entries or the totalEntries. So now I am lost since this is from original.
Logged
Pages: [1] Print 
« previous next »
Jump to:  


Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!