14 Replies Latest reply on Dec 28, 2009 3:16 AM by nikos101

    PHP project problems

    nikos101 Level 2

      I've just fired up my test with a php project created with FB4 and I get a message

       

      Channel disconnected
      Channel disconnected before an acknowledgement was received

       

      I let FB4 install the zend framework in the root of my site and it brought the servicies into FB4. I draged a service onto my datagrid and ran the project

        • 1. Re: PHP project problems
          jdesko Level 2

          Hello nikos;

           

          I usually find that with a channel disconnect the error is somewhere in the PHP class (not FB); anywhere from username, password, to code error.  I always make sure that Network Monitor is enabled and if you have your PHP return data or error code, look at Network Monitor for a response, also check it for the proper data going to PHP in request.  Also, with PHP/SQL errors sometimes I find that I can keep my FB debug session open and modify my PHP while I'm troubleshooting (sometimes I have to clear browser cache), unlike a FB error where you close your debug session, work on FB, then open debug again.

           

          John

          • 2. Re: PHP project problems
            jdesko Level 2

            Nikos;

             

            If your still having this problem, post your network monitor request and response, also your php class/script. 

             

            John

            • 3. Re: PHP project problems
              nikos101 Level 2

              Thanks for your offer:)

               

              I cannot see the network monitor request, I have enabled it and ran in debug

              mode

               

              here's the php:

               

               

               

               

              <?php

               

              /**

               

              • README for sample service

              *

               

              • This generated sample service contains functions that illustrate typical

              service operations.

               

              • Use these functions as a starting point for creating your own service

              implementation. Modify the

               

              • function signatures, references to the database, and implementation

              according to your needs.

               

              • Delete the functions that you do not use.

              *

               

              • Save your changes and return to Flash Builder. In Flash Builder

              Data/Services View, refresh

               

              • the service. Then drag service operations onto user interface components

              in Design View. For

               

              • example, drag the getAllItems() operation onto a DataGrid.

              *

               

              • This code is for prototyping only.

              *

               

              • Authenticate the user prior to allowing them to call these methods. You

              can find more

               

              • information at <link>

              *

              */

              class service {

               

                  var $username = "secret";

                  var $password = "secret";

                  var $server = "localhos";

                  var $port = "";

                  var $databasename = "secret";

                  var $tablename = "tbrawcontactlist";

               

                  var $connection;

               

                  /**

                    

              • The constructor initializes the connection to database. Everytime a

              request is

                    

              • received by Zend AMF, an instance of the service class is created and

              then the

                    

              • requested method is invoked.

                   */

                  public function __construct() {

                        $this->connection = mysqli_connect(

                                                $this->server,

                                                $this->username,

                                                $this->password,

                                                $this->databasename,

                                                $this->port

                                            );

               

                      $this->throwExceptionOnError($this->connection);

                  }

               

                  /**

                    

              • Returns all the rows from the table.

                   *

                    

              • Add authroization or any logical checks for secure access to your

              data

                   *

                    

              • @return array

                   */

                  public function getAllTbrawcontactlist() {

               

                      $stmt = mysqli_prepare($this->connection, "SELECT * FROM

              $this->tablename");

                      $this->throwExceptionOnError();

               

                      mysqli_stmt_execute($stmt);

                      $this->throwExceptionOnError();

               

                      $rows = array();

               

                      mysqli_stmt_bind_result($stmt, $row->id, $row->email,

              $row->dateCreated, $row->wantsEmails);

               

                      while (mysqli_stmt_fetch($stmt)) {

                        $rows[] = $row;

                        $row = new stdClass();

                        mysqli_stmt_bind_result($stmt, $row->id, $row->email,

              $row->dateCreated, $row->wantsEmails);

                      }

               

                      mysqli_stmt_free_result($stmt);

                      mysqli_close($this->connection);

               

                      return $rows;

                  }

               

                  /**

                    

              • Returns the item corresponding to the value specified for the primary

              key.

                   *

                    

              • Add authroization or any logical checks for secure access to your

              data

                   *

                   *

                    

              • @return stdClass

                   */

                  public function getTbrawcontactlistByID($itemID) {

               

                      $stmt = mysqli_prepare($this->connection, "SELECT * FROM

              $this->tablename where id=?");

                      $this->throwExceptionOnError();

               

                      mysqli_bind_param($stmt, 'i', $itemID);

                      $this->throwExceptionOnError();

               

                      mysqli_stmt_execute($stmt);

                      $this->throwExceptionOnError();

               

                      mysqli_stmt_bind_result($stmt, $row->id, $row->email,

              $row->dateCreated, $row->wantsEmails);

               

                      if(mysqli_stmt_fetch($stmt)) {

                          return $row;

                      } else {

                          return null;

                      }

                  }

               

                  /**

                    

              • Returns the item corresponding to the value specified for the primary

              key.

                   *

                    

              • Add authroization or any logical checks for secure access to your

              data

                   *

                   *

                    

              • @return stdClass

                   */

                  public function createTbrawcontactlist($item) {

               

                      $stmt = mysqli_prepare($this->connection, "INSERT INTO

              $this->tablename (id, email, dateCreated, wantsEmails) VALUES (?, ?, ?,

              ?)");

                      $this->throwExceptionOnError();

               

                      mysqli_bind_param($stmt, 'isss', $item->id, $item->email,

              $item->dateCreated, $item->wantsEmails);

                      $this->throwExceptionOnError();

               

                      mysqli_stmt_execute($stmt);

                      $this->throwExceptionOnError();

               

                      $autoid = mysqli_stmt_insert_id($stmt);

               

                      mysqli_stmt_free_result($stmt);

                      mysqli_close($this->connection);

               

                      return $autoid;

                  }

               

                  /**

                    

              • Updates the passed item in the table.

                   *

                    

              • Add authroization or any logical checks for secure access to your

              data

                   *

                    

              • @param stdClass $item

                    

              • @return void

                   */

                  public function updateTbrawcontactlist($item) {

               

                      $stmt = mysqli_prepare($this->connection, "UPDATE $this->tablename

              SET id=?, email=?, dateCreated=?, wantsEmails=?    WHERE id=?");

                      $this->throwExceptionOnError();

               

                      mysqli_bind_param($stmt, 'isssi', $item->id, $item->email,

              $item->dateCreated, $item->wantsEmails, $item->id);

                      $this->throwExceptionOnError();

               

                      mysqli_stmt_execute($stmt);

                      $this->throwExceptionOnError();

               

                      mysqli_stmt_free_result($stmt);

                      mysqli_close($this->connection);

                  }

               

                  /**

                    

              • Deletes the item corresponding to the passed primary key value from

                    

              • the table.

                   *

                    

              • Add authroization or any logical checks for secure access to your

              data

                   *

                   *

                    

              • @return void

                   */

                  public function deleteTbrawcontactlist($itemID) {

               

                      $stmt = mysqli_prepare($this->connection, "DELETE FROM

              $this->tablename WHERE id = ?");

                      $this->throwExceptionOnError();

               

                      mysqli_bind_param($stmt, 'i', $itemID);

                      mysqli_stmt_execute($stmt);

                      $this->throwExceptionOnError();

               

                      mysqli_stmt_free_result($stmt);

                      mysqli_close($this->connection);

                  }

               

               

                  /**

                    

              • Returns the number of rows in the table.

                   *

                    

              • Add authroization or any logical checks for secure access to your

              data

                   *

                   *

                   */

                  public function count() {

                      $stmt = mysqli_prepare($this->connection, "SELECT COUNT(*) AS COUNT

              FROM $this->tablename");

                      $this->throwExceptionOnError();

               

                      mysqli_stmt_execute($stmt);

                      $this->throwExceptionOnError();

               

                      mysqli_stmt_bind_result($stmt, $rec_count);

                      $this->throwExceptionOnError();

               

                      mysqli_stmt_fetch($stmt);

                      $this->throwExceptionOnError();

               

                      mysqli_stmt_free_result($stmt);

                      mysqli_close($this->connection);

               

                      return $rec_count;

                  }

               

               

                  /**

                    

              • Returns $numItems rows starting from the $startIndex row from the

                    

              • table.

                   *

                    

              • Add authroization or any logical checks for secure access to your

              data

                   *

                   *

                   *

                    

              • @return array

                   */

                  public function getTbrawcontactlist_paged($startIndex, $numItems) {

               

                      $stmt = mysqli_prepare($this->connection, "SELECT * FROM

              $this->tablename LIMIT ?, ?");

                      $this->throwExceptionOnError();

               

                      mysqli_bind_param($stmt, 'ii', $startIndex, $numItems);

                      mysqli_stmt_execute($stmt);

                      $this->throwExceptionOnError();

               

                      $rows = array();

               

                      mysqli_stmt_bind_result($stmt, $row->id, $row->email,

              $row->dateCreated, $row->wantsEmails);

               

                      while (mysqli_stmt_fetch($stmt)) {

                        $rows[] = $row;

                        $row = new stdClass();

                        mysqli_stmt_bind_result($stmt, $row->id, $row->email,

              $row->dateCreated, $row->wantsEmails);

                      }

               

                      mysqli_stmt_free_result($stmt);

                      mysqli_close($this->connection);

               

                      return $rows;

                  }

               

               

                  /**

                    

              • Utitity function to throw an exception if an error occurs

                    

              • while running a mysql command.

                   */

                  private function throwExceptionOnError($link = null) {

                      if($link == null) {

                          $link = $this->connection;

                      }

                      if(mysqli_error($link)) {

                          $msg = mysqli_errno($link) . ": " . mysqli_error($link);

                          throw new Exception('MySQL Error - '. $msg);

                      }

                  }

              }

               

              ?>

               

               

               

               

               

               

               

               

               

              best wishes

               

               

              2009/11/14 jdesko <forums@adobe.com>

               

              Nikos;

              >

              If your still having this problem, post your network monitor request and

              response, also your php class/script.

              >

              John

              >

              • 4. Re: PHP project problems
                David_F57 Level 5

                Hi,

                 

                I have exactly the same problem with channel disconnects, so far from what I can see is that the response is failing because the service classes can't interprete the amf, this is a zend problem as I have no issues with amfphp using either wamp or xampp, I was actually surprised that after 5 months and several en drops of FB that I can actually get through the whole dataservices wizard without everything falling apart.

                 

                So now zend fails with wamp 2.0i and xampp 1.7.2.  and the zend server CE just fails(well its from zend so I suppose that much was a given) so can't even test the dysfunctional zendframework against its cousin the dysfunctional zend CE server.

                 

                 

                I've attached the screen shot of the netmonitor, the mysqli_connect parameters seem to be an issue, but I haven't done anything this is all generated code and the wizards happily connected and retrieved data to prepare the datagrid columns.

                 

                David

                • 5. Re: PHP project problems
                  nikos101 Level 2

                  Its only beta software, these issues will get ironed out, The coldfusion stuff works a charm

                  • 6. Re: PHP project problems
                    David_F57 Level 5

                    Well i don't know if its going to get better zend response time is incredibly slow compared to the original amfphp it doesn't have things like the class browser that amfphp has. A joy to work with when testing php classes. Zend is just a 25mb mess compared to the fast reliable easy to use amfphp.

                     

                    Anyway this should help with your disconnects - remove the port variable and comma after database name so your connection string looks like this

                     

                        public function __construct() {

                              $this->connection = mysqli_connect(

                                $this->server,

                                $this->username,

                                $this->password,

                               $this->databasename );

                     

                            $this->throwExceptionOnError($this->connection);

                        }

                     

                    David

                    • 7. Re: PHP project problems
                      sudhirm-rRcgag Adobe Employee

                      Hi,

                       

                      Were you able to solve the problem after  following David's suggestion? Adding to it, I also see that there is a "t" missing from "localhost". This can also be the cause for the problem.

                       

                      Thanks,

                      Sudhir

                      • 8. Re: PHP project problems
                        David_F57 Level 5

                        Hi,

                         

                        Additional info to this, it seems that for some reason when the port is a null string i.e. ="" this causes the fault as an integer cvalue is expected is the port number is put in ie. port="3306" the conversion is done to an int and all is well. Maybe the port needs to automatically default this value which would alleviate the issue for autogeneration, now if only zend could perform stablely outside a hobbyists environment.

                         

                        As usually just when you think you've got a handle on zend it throws another problem, seems that zend decided to add to their incompetence and total lack ogf intelligence by ensuring that zendamf won't work on anything less than the latest stable release of php, which basically means it won't work on over half the worlds hosts.

                         

                        David.

                        1 person found this helpful
                        • 9. Re: PHP project problems
                          nikos101 Level 2

                          Any one managed to get this to work yet?


                          • 10. Re: PHP project problems
                            David_F57 Level 5

                            Hi,

                             

                            It just gets worse ,

                             

                            I finally find a host that has php 5.2.3 and they update zend to 5.2.4, i'm now organizing a test with virtual machine hosting which allows me to have my own setup but this totally ludicrous, if I go back to old versions of zend it won't work with flashbuilder, flashbuilder is stuck somewhere in the middle becuase now I can't get Flashbuilder to work with new versions of Zend, there are virtually no examples anywhere of zendamf working in the real World and incase Zend is listening Zend Server is not the real world unless we are talking about comedy circuits. CPanel which is only the largest hosting control panel in the world refuses to update php because of the immense global consequence of such a move. Meanwhile back in fairy land Zend just keep updating the minimum php requirement oblivious to the fact that the world doesn't revolve around their paranoid delusions of grandeur.

                             

                            What is really upsetting me is for the first time in several months it looked like I was going to get a decent job with a flex project until some silverlight dude rocks up and in less time than it takes to spell zend he has silverlight running my fracken server end amfphp.

                             

                            David.

                            1 person found this helpful
                            • 11. Re: PHP project problems
                              nikos101 Level 2

                              Sorry to hear about that

                              • 12. Re: PHP project problems
                                jdesko Level 2

                                Hello nikos and David;

                                 

                                If I can offer a suggestion ... Can you try minimizing your php service and take it one function at a time?  First just try only connecting and if it is error free then add only one function and in FB just do that one function at a time.  Also, while your troubleshooting leave out all comments, keeping the code minimal. 

                                 

                                Again, I find in debug mode on the local machine network monitor a must, then with the production server using something like charlie (they have a free eval period but it's inexpensive to buy), to help in troubleshooting and looking at the data request/response and php error response.  Hopefully you can get network monitor working.

                                 

                                @David - sorry to hear about everything, I feel for you.  In response to:

                                there are virtually no examples anywhere of zendamf working in the real World

                                My setup for my current app is I am using Network Solutions for the host services, php/mysql/FB and zend framework (are they using the latest version of php/mysql - probably not).  Again, I am using mysql and not mysqli; I have at this time 24 tables but there should be more.  Everything is working like a charm.  In response to the real world, I hope to have my app running a beta version by tomorrow night, right now what's up is limited by password only for checking design and certain functions.  I hope to migrate off of Net Sol standard services soon.  Speed and security are a number one issue, I haven't compared this app using amf though, I want the app up first and want to stick with everything FB out of the box.  Just wanted to mention what's working for me; speed though? we'll see.

                                 

                                John

                                • 13. Re: PHP project problems
                                  jdesko Level 2

                                  Hello nikos;

                                   

                                  Maybe I misunderstood, you said

                                  I cannot see the network monitor request, I have enabled it and ran in debug

                                  mode

                                  Is network monitor working?  If so you should at least see a request.  If I put in a bad password in my php script for logging in to sql,  I get a channel disconnected error, but I can see the client's request and in my php script for logging in I have it return an error, which I see in response.

                                   

                                  John

                                  • 14. Re: PHP project problems
                                    nikos101 Level 2

                                    It worked after Davids idea, but its real slow compared to amfphp