Hi every body, i am new in this forum that i find very interessting
i have an error notice with one of my function,
"Notice: Array to string conversion in C:\wamp\www\waypointhr\components\data_view_join.php on line 118 see below in the line"

this error concerns this line: if((string)$row['callback_function']!=='')
see the holl function below

function render() {
        global $global_params;
        global $global_db_engine;

        $html='';

        $set=$global_db_engine->select_join($this->source,$this->columns);

        //if($set!==false) {

            if($this->retain_data) {
                $this->retained_data=$set[0];
            }

            $html="<table class=\"editable\">\n";
            foreach($this->rows as $row) {
                $content_string='';

                if(is_string($row['column'])&&$row['column']==='') {
                    // Plain text - no columnar specification
                    $content_string=$row['title'];
                    $row['title']='';
                } else {
                    if((string)$row['callback_function']!=='') {
                        // Callback requested
                        $content_string=call_user_func($row['callback_function'],$set[0]);
                    } else {
                        if(is_string($row['column'])) {
                            if(count($set)===1) {
                                //$content_string=$set[0][$row['column']];
                                if($row['column']!=='') {
                                    $col_spec=$this->_split_column($row['column']);
                                    $content_string=$this->_render_column($col_spec['source'],$col_spec['column_name'],$set[0]  [$row['column']]);
                                }
                            } else {
                                // TODO: Implement display of multiple records
                                $content_string="?";
                            }
                        } elseif (is_array($row['column'])) {
                            //TODO:
                            $content_string="?";
                        } else {
                            // Huh?
                        }
                    }

                    if(!array_key_exists('section',$global_params['qs'])) {
                        $global_params['qs']['section']='';
                    }
                    if((string)$row['id']!=='') {
                        $edit_link_tag_open='<a href="#" class="edit" onclick="showEditor('.(string)(int)$global_params['qs']['id'].',\''.$row['id'].'\',\''.$global_params['qs']['section'].'\');">';           
//$edit_link_tag_open=debug($row).'url'.$edit_link_tag_open;
                        $content_string="{$edit_link_tag_open}{$content_string}</a>\n";
                    } else {
                        $edit_link_tag_open='';
                        $content_string="<span class=\"nolink\">{$content_string}</span>\n";
                    }
                }

                if((string)$row['title']!=='') {
                    $add_item_link='';  // TODO: Add new item not yet implemented
                    $html.="\t<tr><td class=\"title\">{$row['title']}{$add_item_link}</td><td>{$content_string}</td></tr>\n";
                } else {
                    $html.="\t<tr><td colspan=\"2\">{$content_string}</td></tr>\n";
                }
            }
            $html.="</table>\n";
        //}

        return $html;
    }

The error message is saying that the value of $row['callback_function'] is an array and can not be cast to string.
In order ot find out what the value is when the error occurs you have to do some simple debugging (if you are not using a proper debugger). Put this code immediatelly after line 16 in the above code:

if(is_array($row['callback_function'])) die(print_r($row['callback_function'], 1));

This will stop the execution once it gets to the point where casting to string is not possible (the value to cast is an array) and display the value. Post the value here.

Also read this and this.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.