3 Replies Latest reply: Feb 19, 2013 6:15 AM by paulkenneth RSS

    A problem of Channel disconnected(Flex & PHP)

    CNKratos Community Member

      Hi there,

      I am also a rookie of Flex. Recently,I try to learn it with the Adobe’s tutorials which locals on:

      First.JPG

      http://www.adobe.com/cn/devnet/flex/testdrive/articles/2_modify_the_database.html#links

      However,when I attempt to add some employees as the tutorial

      Second.JPG

      says,there always be an error:

      Channel disconnected

      Channel disconnected before an acknowledgement was received

      Even though I searched for the solution a lot times,I haven’t find a appropriate one.

      It bothers me several days

      So, if you guys knew how to figure it out , please do me a favor.

      Thanx a lot

      Nick

        • 1. Re: A problem of Channel disconnected(Flex & PHP)
          Vixborn Community Member

          SOLUTION:

           

          When you follow the TestDrive tutorial you assume that all the syntax is 100% OK. That is not the case here.

           

          If you try to use the functions createEmployee(), updateEmployee() or deleteEmployee() you will notice that it needs to bind the parameters to the $stmt variable. When the PHP service (in this case:  EmployeeService) is called and the function reaches the point where the binding is performed the PHP will return a PHP Fatal error (you may check on your PHP log - usualy in C:\xampp\php\logs\php_error_log)  informing that there is a Call to undefined function mysqli_bind_param().

           

          To solve this you must  change your code as described below:

           

                Let's assume we are working with the function createEmployee()

           

            public function createEmployee($item) {

               $stmt = mysqli_prepare($this->connection,

               "INSERT INTO employees (

               firstname,lastname,title,departmentid,officephone,cellphone,

               email,street,city,state,zipcode,office,photofile)

               VALUES (?, ?, ?, ?, ?, ?,?,?,?,?,?,?,?)");

               $this->throwExceptionOnError();

           

           

          all the same until now... BUT, notice the very beggining of the next statement...

           

                    $stmt->bind_param('sssisssssssss', $item->firstname, $item->lastname,

                              $item->title, $item->departmentid, $item->officephone, $item->cellphone,

                              $item->email, $item->street, $item->city, $item->state,

                              $item->zipcode, $item->office, $item->photofile);

           

          ------------------

           

          When you check the original code you will notice that the

                 mysqli_bind_param($stmt, 

           

          was replaced by

                 $stmt->bind_param(.

           

          This will solve the problem for good

           

          Best regards!

           

          Pitagoras

           

          • 2. Re: A problem of Channel disconnected(Flex & PHP)
            raghavmb007 Community Member

            The issue is because mysqli_bind_param() function has been DEPRECATED as of PHP 5.3.0 and REMOVED as of PHP 5.4.0.

             

            Source: http://php.net/manual/en/function.mysqli-bind-param.php

             

            Replacing that with mysqli_stmt_bind_param() works .

             

            Cheers,

            raghu

            • 3. Re: A problem of Channel disconnected(Flex & PHP)
              paulkenneth Community Member

              Amazingly helpful! Thank god people like you exist because you just helped me massively!