Welcome, Guest. Please login or register.
Did you miss your activation email?
05/16/12, 22:58
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
| |-+  Flash Remoting with AMF (Moderators: Flash-db, Musicman, Jorge Solis, papachan, nothingGrinder)
| | |-+  trigger_error()
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] Print
Author Topic: trigger_error()  (Read 7470 times)
Micah Caldwell
Server what's that
*
Posts: 36



View Profile Email
« on: 10/12/04, 22:12 »

How do you use this?  I put this line in my code:
trigger_error("Testing");
and I get that NetConnectionBadCall thingy (No "Testing").
I also tried
trigger_error("Testing", E_USER_ERROR);
and got the same results.

I need to test some changes to AMFPHP code, and trigger_error seems to be the only way to get data sent back to the client for error reporting.

(note: running the latest CVS with a few modifications for PHP5 and mysqli).

-Micah

Edit:  If anyone knows of a different or better way to debug the AMFPHP code, please let me know.

To give a little background, I am trying to add mysqli functionality to AMFPHP (PHP5 + MySql 4.1+).  I have created a file mysqliAdapter.php based on mysqlAdapter.php and edited it with the proper mysqli functions (replacing the old mysql functions).  However, all I ever get returned to the NetDebugger in Flash MX 2004 is [object Object]s.  I am pulling my hair out trying to find what is wrong, but to no avail.

On the same topic, when specifying a return type I put:
"returntype" => "mysqli result"
right?  I have tried a number of other things, but based on the AMFPHP files that appears to be the format it is looking for (it strips off " result" then takes what is left and adds "Adapter.php" to the end of it).
« Last Edit: 10/13/04, 00:52 by Micah Caldwell » Logged
Jorge Solis
Administrator
Systems Administrator
*****
Posts: 14600


View Profile
« Reply #1 on: 10/13/04, 08:06 »

Did you try a for in loop to know more about the structure of the object amfphp is returning?

Jorge
Logged

Micah Caldwell
Server what's that
*
Posts: 36



View Profile Email
« Reply #2 on: 10/13/04, 09:54 »

trace(result) gives [object Object]
trace(result[ 0 ]) gives undefined

I think that AMFPHP isn't even calling mysqliAdapter.php because I can put a typo, or blatant error in the code there and I still recieve [object Object] with no problems.
« Last Edit: 10/13/04, 09:58 by Micah Caldwell » Logged
Micah Caldwell
Server what's that
*
Posts: 36



View Profile Email
« Reply #3 on: 10/13/04, 10:18 »

I have this,
Code:
"GetList" => array
(   "description" => "Returns a list of all notes.",
   "access" => "remote",
   "returns" => "mysqli result"
)

yet by the time the code gets to:
Code:
function writeData($d, $type = -1)

type is -1 (or not set and then set to -1).

I have also tried "returntype" but the code in RemotingService.php indicates that it should be "returns".

Does anyone know why I wouldn't be getting a returntype?
Logged
Jorge Solis
Administrator
Systems Administrator
*****
Posts: 14600


View Profile
« Reply #4 on: 10/13/04, 15:48 »

Hi Micah

Just installing PHP 5.02
I must to rename Exception class and all its calls so something else (Amf_Exception in my case)
Then all works fine.
Using trigger_error() breaks the output, just giving a Badversion. Anyway Exceptions.php sets the set_error_handler to reportExceptions ... should check better this.
Using throwException (or throw Amf_Exception now) needs a reference to the body that I'm not sure how to build (it's a member in ClassLoaderAction.php and SecurityAction.php, the two classes I see are using exceptions)

About type checking, the autoNegotiateType function can try to find the correct resource (try get_resource_type()) but probably you should manually add in the switch block of the manualType function (AMFSerializer.php), so the library can use your custom type.

Jorge
Logged

Micah Caldwell
Server what's that
*
Posts: 36



View Profile Email
« Reply #5 on: 10/13/04, 21:00 »

I have already renamed Exception class (and all it's components) to AMF_Exception.

I also made the __construct change as listed on the AMFPHP mailing lists, and perhaps that is the problem I am running into.  I will try changing that back to see if everything works as expected.

Unfortunately, for some reason my functions are not passing a type, and autonegotiate can't detect recordsets I don't think.  Sad
Logged
Micah Caldwell
Server what's that
*
Posts: 36



View Profile Email
« Reply #6 on: 10/13/04, 23:06 »

I converted all my functions to mysql, and it properly returns the results.  However, no matter what I do, the $type sent to AMFSerialize is *always* -1.  The gettype() function is somehow determining that my type is a "mysql result" at which point everything runs smoothly.

However, I don't know how to add "mysqli result" to the types that gettype() can detect and therefor I can never get to the point at which AMFPHP calls mysqliAdapter.php, since "results" doesn't appear to do anything at all.

To top it all off, gettype is no longer supported (was phased out in PHP3) so finding help on it is quite difficult.  Sad

-Micah
Logged
Jorge Solis
Administrator
Systems Administrator
*****
Posts: 14600


View Profile
« Reply #7 on: 10/14/04, 01:33 »

As posted, you need to add your custom recordset. The library serialize it in this part:

[script]
//File AMFSerializer.php
//Line 398

   function manualType($d, $type)
    {
        $type = strtolower($type);
        $dbtype = $type; // save this here incase we need it in a few lines
        $result = strpos($type , " result"); // first check to see if this is a recordset do this here for efficiency
        if ($result !== FALSE) {
            $type = "__RECORDSET__";
        }
        switch ($type) {
         case "__recordsetpage__" :
            $this->writeRecordSetPage($d);
            break;
            case "__RECORDSET__" :
                $resultType = substr($dbtype, 0, $result);
                $classname = $resultType . "Adapter"; // full class name
                $includeFile = @include_once(AMFPHP_BASE . "sql/" . $classname . ".php"); // try to load the recordset library from the sql folder
                if(!$includeFile) {
                    if (!@include_once($classname . ".php")) {// try from the same folder as the service
                        trigger_error("The recordset filter class " . $classname . " was not found");
                    }
                }
                $recordSet = new $classname($d); // returns formatted recordset
                $this->writeRecordSet($recordSet); // writes the recordset formatted for Flash
                break;
               .....
[/script]

Note that based on the type you pass (if it ends with result it assumes a recordset) the first switch makes proper includes.


Jorge
« Last Edit: 10/14/04, 01:35 by Jorge Solis » Logged

Micah Caldwell
Server what's that
*
Posts: 36



View Profile Email
« Reply #8 on: 10/14/04, 09:39 »

I found out my problem.  I was using the latest CVS which is pretty broken.  :p

As soon as I switched to the 0.9 off the website everything started working.  It appears that the latest CVS completely ignores the "results" field when setting up your meathod, so my mysqliAdapter.php code was never getting called (nor was the _RECORDSET_ code ever getting called).

-Micah
Logged
a
Server what's that
*
Posts: 3



View Profile Email
« Reply #9 on: 03/04/05, 20:20 »

Hi - has anyone made a step-by-step procedure for modifying amfphp to work with php5?  I have an app that I have been using for almost two years that I dont think I have the latest fla's for.  Cry    We were forced to upgrade our server to php5, and now the application does not function.  I saw a post with regard to changing the AMF__construct and adding in that else statement.  Aside from that, what else needs to be done?  Before I start pulling my hair out while trying to debug in flash, I wanted to make sure that I set up as much as possible on the server for php5.


Thanks!
Logged
Jorge Solis
Administrator
Systems Administrator
*****
Posts: 14600


View Profile
« Reply #10 on: 03/05/05, 02:23 »

Nothing special. Use a test movie (just a Hello World, even this: http://www.flash-db.com/Tutorials/hello/ to test if it works. Keep an eye on the NetConnection Debugger.

Jorge
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!
anything