Welcome, Guest. Please login or register.
Did you miss your activation email?
05/22/12, 18:49
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
|-+  General
| |-+  Flash and AS 3 (Moderators: papachan, kofi addaquay)
| | |-+  Is this possible?
0 Members and 2 Guests are viewing this topic. « previous next »
Pages: 1 [2] Print
Author Topic: Is this possible?  (Read 1631 times)
klops12
Server what's that
*
Posts: 20


View Profile
« Reply #15 on: 07/15/11, 02:07 »

The thing is Ronald, that I need two counters and in text output panel comments should appear according to their input time from two tables. Right now here are some errors, but I am working on them. Smiley
Logged
Ronald Wernecke
Administrator
Systems Administrator
*****
Posts: 6175


View Profile WWW Email
« Reply #16 on: 07/15/11, 04:46 »

"Some errors" is not realy expressiv Wink

If you have more details, we might be able to put you into the right direction.
Logged

happy flashing
Cool
Ronald
klops12
Server what's that
*
Posts: 20


View Profile
« Reply #17 on: 07/15/11, 06:05 »

Ok, when I will get home from work, I will be more detailed, but now You can check www.avsb1.byethost2.com, I think few errors are obvious. Cheesy
Logged
Ronald Wernecke
Administrator
Systems Administrator
*****
Posts: 6175


View Profile WWW Email
« Reply #18 on: 07/15/11, 11:01 »

Hi Klops,
I just checked a little:

in the left entry, you are requesting GuestBook3.php, which does not exist.

in the right side, you receive entries, but you propably have a mistyped variable and you have some interfering html codes in your response.

Remove the first br tag in the variable list and make sure your receiving variable is named entries.

Be aware, that flash knows the difference of capital letters.

So, if your variable is named Entries, it cannot receive data for entries.
Logged

happy flashing
Cool
Ronald
klops12
Server what's that
*
Posts: 20


View Profile
« Reply #19 on: 07/17/11, 06:56 »

Finally left side is working, but still entries doesn't show up, maybe code will help to solve this small problem:
<?
   $DBhost = "sql306.byethost2.com";   // Database Server
   $DBuser = "b2_8264108";            // Database User
   $DBpass = "**********";            // Database Pass
   $DBName = "b2_8264108_GuestBook2";            // Database Name
   $table = "guestbook";             // Database Table
   $table1 = "guestbook1";             // Database Table
   $numComments = 10;       // 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 "&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');
            $comments = mysql_result($fewComments, $i, 'comments');
            $time = mysql_result($fewComments, $i, 'time');
            
            print '<b>Name: </b>' . $name . '<br><b>Email: </b>' . $email . '<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']);
       $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`,
               `comments`,
               `time`
              )
              VALUES
              (\'\','
               . '\'' . $name . '\','
               . '\'' . $email . '\','
               . '\'' . $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
      
 
       print "&gb_status=Thank you for signing my guestbook.&done=yes&";
       return;
       }
       print "&_root.write.gb_status=Error!&";
       break;
   }
   // 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 `' . $table1 . '`';
       $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 '&totalEntries1=' . $numallComments . '&';
       print "&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');
            $comments = mysql_result($fewComments, $i, 'comments');
            $time = mysql_result($fewComments, $i, 'time');
            
            print '<b>Name: </b>' . $name . '<br><b>Email: </b>' . $email . '<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['yourname1']);
       $email = ereg_replace("&", "%26", $_POST['youremail1']);
       $comments = ereg_replace("&", "%26", $_POST['yourcomments1']);
       $submit = $_POST['submit1'];
          
       // 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($submit1 == 'Yes'){
       // Insert the data into the mysql table
       $sql = 'INSERT INTO ' . $table1 .
                ' (`ID`,
               `name`,
               `email`,
               `comments`,
               `time`
              )
              VALUES
              (\'\','
               . '\'' . $name . '\','
               . '\'' . $email . '\','
               . '\'' . $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
            
       print "&gb_status1=Thank you for signing my guestbook.&done=yes&";
       return;
       }
       print "&_root.write.gb_status1=Error!&";
       break;
   }

?>
Logged
klops12
Server what's that
*
Posts: 20


View Profile
« Reply #20 on: 07/17/11, 13:15 »

Checked letter capitalize, everything is OK, I don't get it why it doesn't show entries. Sad
Logged
Ronald Wernecke
Administrator
Systems Administrator
*****
Posts: 6175


View Profile WWW Email
« Reply #21 on: 07/18/11, 06:46 »

OK, you concatinated both requests.

But in this case, you have to concatinate the output as well.
Otherwiese you receive only the second entries.

I have no idea, whay you need two different guestbooks to be concatinated into one output.
But this fact confuses you.

In Part two, you have to change:
Code:
// Generate Output for Flash to Read
       print '&totalEntries1=' . $numallComments . '&';
       print "&entries1=";   
and concatinate it at the flash side:
Code:
entries.text=receivedData.entries+"<br>"+receivedData.entries1;

or alike. I dont know, how you named your objects and variables.

Or you collect all the entries into a variable at php side, and send them as a block down the line.
Logged

happy flashing
Cool
Ronald
Ronald Wernecke
Administrator
Systems Administrator
*****
Posts: 6175


View Profile WWW Email
« Reply #22 on: 07/20/11, 02:17 »

OK, I can seee, you changed something.
Now you renamed the button actions and call the same procedure.
This is the right way.
But still somehow you are not reading the response right.
The server delivers a text, but you dont fetch it into the textbox.
Anyway, the textbox is refreshing, after it received new data.

The reason must lie in your onData handler inside action script.
Logged

happy flashing
Cool
Ronald
klops12
Server what's that
*
Posts: 20


View Profile
« Reply #23 on: 07/20/11, 11:50 »

OK, corrected line in flash "entries.text = this.entries + this.entries1;"
Now it is weird.
If You enter A side you can see only A entries, if you submit B entry You can see B entries and A entries without submited information, only name, email and comments.
Logged
Ronald Wernecke
Administrator
Systems Administrator
*****
Posts: 6175


View Profile WWW Email
« Reply #24 on: 07/21/11, 02:19 »

somehow your concatination does not work.

I will check with charles later today.
Logged

happy flashing
Cool
Ronald
Pages: 1 [2] 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!