[swx] swx 1.01 - Error 256: Unhandled data type (resource) in SwxAssembler.php, line 145.

swx thswx at tomhollins.com
Fri Jan 4 23:10:08 PST 2008


Ok, last message sent from wrong email account. Sorry. Here is more 
info. I modified the SwxAssembler.php to output the $data as well. The 
error now reads:
Error 256: Unhandled data type (resource)  data(Resource id #10) in 
(mypath)php/SwxAssembler.php, line 145.

Having problems with the call to the "getFilterQuestions". However the
addNumbers works. I was going to hack the code but I figured I would
post first and hack later (the minute after posting).
Its odd since the Service Explorer was used to test out every function
(I chopped all code out except the ones in question).
I then went and developed the swxtest flash code with this code, a text
box named status and a textarea called taResults. If you do that then
you have everything I have.
I looked at the code from SwxAssembler.php and its in this function
(code below). Maybe php4.4.4 has a new datatype or the gettype has a bug
in it. I will post back if I find anything. Also if there is a better
way to post please tell me.
    /**
     * Parses the given data structure (any type) and
     * returns SWF bytecode.
     *
     * @param    any        A PHP data structure
     * @return     string    Swf bytecode representation of the data
structure.
     * @author Aral Balkan
     **/
    function dataToBytecode ($data)
    {
        $type = gettype($data);

        switch($type)
        {
            case 'array':
                $bytecode = $this->arrayToBytecode($data);
                break;

            case 'object':
                // TODO: Handle objects natively without
                //       converting to an associative array.

                // Convert object to array
                $data = $this->objectToArray($data);

                // And then use the array encoder
                $bytecode = $this->arrayToBytecode($data);
                break;

            case 'string':
                $bytecode = $this->stringToBytecode($data);
                break;

            case 'integer':
                $bytecode = $this->integerToBytecode($data);
                break;

            case 'double':
                $bytecode = $this->doubleToBytecode($data);
                break;

            case 'boolean':
                $bytecode = $this->booleanToBytecode($data);
                break;

            case 'NULL':
                $bytecode = DATA_TYPE_NULL;
                break;

            default:
                trigger_error('Unhandled data type ('.$type.')',
E_USER_ERROR);
                //error_log('[SWX] ERROR dataToBytecode() Unhandled data
type: ' . $type);
                //$bytecode = "ERROR";
        }

        return $bytecode;
    }


MY Flash 8.0 Actionscript code. The PHP server code is below this
<----------------------------------->

import org.swxformat.SWX;

var swx:SWX = new SWX();
swx.gateway = "http://www.(website).com/swx/php/swx.php";
swx.encoding = "POST";
swx.debug = true;

var callParameters:Object =
{
    serviceClass: "Service",
    method: "getFilterQuestions",
    args: [0],
//    method: "addNumbers",
//    args: [11,34],
    result: [this, resultHandler],
    fault: [this, faultHandler]
}

swx.call(callParameters);

function resultHandler(event:Object)
{
    status.text = event.result;
    taResults.text = event.result;
}

function faultHandler(event:Object)
{
    taResults.text = event.fault.message;
}

PHP 4.4.4 on the server with MySQL 3.2.3. PHP code follows:

<?php
    //require_once('./dbConnect.php');

    /**
     * Provides all of the functions for the Service to operate
     *
     * @package default
     * @author Thomas A. Hollins
     **/
    class Service
    {
        /**
         * addNumbers is here to test that this class works
         *
         * @param First number to add
         * @param Second number to add
         *
         * @return The additive result of the two numbers passed to this
method
         * @author Aral Balkan
         **/
        function addNumbers($n1, $n2)
        {
            return $n1 + $n2;
        } // addNumbers

        /**
         * Returns the filter questions, fields, etc. for a particular
category
         *
         * @param Category displayorder or some part of the category label.
         * @return Array with Category display label, filter label,
field type, variable type
         * @author Thomas A. Hollins
         **/
        function getFilterQuestions($category)
        {
            require('/www/cgi-bin/fcdbconnect.php');
            $sql =  "SELECT DISTINCT fcs_category.displaylabel,
fcs_feature.name, " .
                    "fcs_filter.display, fcs_filter.description,
fcs_filter.comptype, " .
                    "fcs_filter.fieldtype, fcs_filter.variabletype,
fcs_vehfeature.value " .
                    "FROM fcs_category, fcs_featurecategory,
fcs_feature, fcs_filter, fcs_vehfeature WHERE ";
            if (is_numeric($category))
            {
                $sql .= "fcs_category.displayorder = " . $category . " ";
            } else {
                $sql .= "fcs_category.displaylabel LIKE '%" . $category
. "%' ";
            } // if
            $sql .= "AND fcs_category.category_uid =
fcs_featurecategory.category_uid " .
                    "AND fcs_feature.feature_uid =
fcs_featurecategory.feature_uid " .
                    "AND fcs_feature.feature_uid =
fcs_filter.feature_uid " .
                    "AND fcs_feature.feature_uid =
fcs_vehfeature.feature_uid";
            return mysql_query($sql);
        } // getFilterQuestions

    } // END class Service
?>





More information about the swx mailing list