1 Reply Latest reply on Mar 6, 2012 8:45 AM by jtveter

    Channel.Call.Failed NetConnection.Call.Failed: HTTP: Status 500 with amfphp php and mysql

    jtveter

      I have been scripting a simple database connection to check login credentials and am comming accross these errors:

       

      Channel.Call.Failed

      NetConnection.Call.Failed:

      HTTP: Status 500

       

      Any PHP code I run that is not connecting to MYSQL runs fine. But if I try to connect to the database thats what I get.

       

      Here is my mxml:

       

      <s:RemoteObject id="LogInService"

                                   source="Novus.NovusUser.getLogIn"

                                   destination="AMFPHP"

                                                                  fault="faultHandler(event)"

                                   showBusyCursor="true">

       

                                    <s:method name="getLogIn" result="onResult(event)" fault="faultHandler(event)"/>

      </s:RemoteObject>

       

       

       

      Which calls this actionscript:

       

      private function btn(event:Event):void

      {

                                                   switch(event.target.id)

              {

                                                             case "LogInSubmit":

       

                                                                            LogInService.getLogIn(UserName.text, PW.text)

       

                    break;

       

                                                   }

                                    }

       

                                    private function onResult(result:ResultEvent):void

                                    {

                                                   Alert.show("Result " + result.token.result);

                                                   if(result.token.result == true)

                                                   {

                                                                  currentState = "Main";

                                                   }

                                                   else

                                                   {

                                                             Alert.show(String(result.token.result));

                                                   }

                                    }

       

                                    private function faultHandler(fault:FaultEvent):void

                                    {

                                                   CursorManager.removeBusyCursor();

              var errorMessage:String = "code:\n" + fault.fault.faultCode + "\n\nMessage:\n" + fault.fault.faultString + "\n\nDetail:\n" + fault.fault.faultDetail;

                                                   Alert.show(errorMessage);

                                    }

       

       

       

       

      and calls this PHP:

      If I comment out the database connection it returns a false value to me just fine but with it there it throws an error

       

      <?php

      class GetLogIn

      {

                     private $_db;

       

                     public function getLogIn($U, $P)

                     {

       

                               //Connect To Database

                               $hostname='127.0.0.1';

                               $username='root';

                               $password='*********';    //not realy ***** blocked it out

                               $dbname='mydatabase';

       

       

                               try

                               {

                                              mysql_connect($hostname,$username, $password) OR DIE ('Unable to connect to database! Please try again later.');

                                              mysql_select_db($dbname);

       

                                              $sql = "Select * FROM empusr WHERE UserName = '$U' and Password = '$P'";

       

                                              mysql_close();

       

                                              if ($sql)

                                              {

                                                             return true;

                                              }

                                              else

                                              {

                                                             return false;

                                              }

       

              }

                               catch

                               {

                                              return 'Unable to connect to database! Please try again later.';

                               }

          }

      }

      ?>

       

      I have a crossdomain.xml but I am unsure if I have it placed right.

      I also have a services.conf but am unsure if that also needs to be altered to adjust for MySQL.

       

      Any help would be appreciated. 

        • 1. Re: Channel.Call.Failed NetConnection.Call.Failed: HTTP: Status 500 with amfphp php and mysql
          jtveter Level 1

          Found the problum

           

          The connection string had to be placed in the public _constructor function of the class.

           

          <?php

           

           

          class EmployeeService

          {

           

                    public function __construct()

                    {

                              $hostname='127.0.0.1';

                              $username='root';

                              $password='*********';

                              $dbname='myDatabase';

           

                              mysql_connect($hostname,$username, $password);

           

           

                              mysql_select_db($dbname);

                    }

           

                    public function logIn($N, $P)

                    {

                              $query = "SELECT * FROM EmpUsr WHERE UserName = '$N' AND Password = '$P'";

           

                              $result = mysql_query($query);

           

           

                                if ($result)

                                {

                                          return true;

                                }

                                else

                                {

                                          return false;

                                }

                    }

           

          }

          ?>