//FCK
vendor("FCKeditor.fckeditor");
$editor = new FCKeditor();
$editor->Width  = '100%';
$editor->Height = '400';
$this  ->Value  = $_POST['content'];
$editor->InstanceName = 'content';
$fckHtml = $editor->Createhtml();
$this->assign('fckHtml',$fckHtml);上面代码在ADD方法使用没有错误,而在EDIT方法使用提示:非法操作ThinkPHP,什么问题呢?请高手指教!

解决方案 »

  1.   

    没提示非法操作什么吗?
    public function index()
    {……//其他代码
    vendor(”FCKeditor.fckeditor”);//包含FCKeditor类库,TP引入第三方类库的系统方法,其路径是相对于vendor目录来说的。
    $editor= new FCKeditor();   //实例化FCKeditor对象
    $editor->Width=’980′;//设置编辑器实际需要的宽度。此项省略的话,会使用默认的宽度。
    $editor->Height=’400′;//设置编辑器实际需要的高度。此项省略的话,会使用默认的高度。
    $this->Value=”;//设置编辑器初始值。也可以是修改数据时的设定值。可以置空。
    $editor->InstanceName=’comment’;//设置编辑器所在表单内输入标签的id与name,即<input>标签的id与name。此处假            //设为comment.此处不可省,也要保持唯一性。表单上传到服务器处理程序后,即可通过$_POST['comment']来读取。
    $html=$editor->Createhtml();//创建在线编辑器html代码字符串,并赋值给字符串变量$html.
    $this->assign(’html’,$html);//将$html的值赋给模板变量$html.在模板里通过{$html}可以直接引用。
    …….//其他代码,包括输出模板。
    }
      

  2.   

    1# 没有其他提示,就这个提示而已。你的代码我也试过了,不行。
    我就觉得奇怪,为什么在 function add(){}没有错误,在function eidt(){}就有错误。
      

  3.   

    实在找不出来.那你就把add方法完全照抄一遍.改个方法名字试试。
      

  4.   

    纠结了,add方法完全照抄一遍还是有同样的错误提示。
      

  5.   

    //添加
    public function add()
    {
    //FCK
    vendor("FCKeditor.fckeditor");
    $editor = new FCKeditor();
    $editor->Width = '100%';
    $editor->Height = '400';
    $this  ->Value = '';
    $editor->InstanceName = 'content';
    $fckHtml = $editor->Createhtml();
    $this->assign('fckHtml',$fckHtml);

    import("App.Model.ProductcategoryModel");
    $Productcategory = D("Productcategory");
    $Productcategory = $Productcategory->order("id desc")->findAll(); import('ORG.Util.Tree');
    $tree=new tree($Productcategory);
    $str="<option value=\$id \$selected>\$spacer\$title</option>";
    $html.=$tree->get_tree(0,$str,-1);
    $this->assign('html',$html);

    $this->display();
    }
    //EDIT
    public function edit()
    {
    $Product = D("Product");
    $date = $_POST;
    $id = $_GET["id"];
    if (!$id) $this->error(L('_SELECT_NOT_EXIST_'));

    $ProductList = $Product->find($id);
    if (!$ProductList) $this->error(L('_SELECT_NOT_EXIST_'));
    //FCK
    vendor("FCKeditor.fckeditor");
    $editor = new FCKeditor();
    $editor->Width  = '100%';
    $editor->Height = '400';
    //$this  ->Value  = $date['content'];
    $this  ->Value  = '';
    $editor->InstanceName = 'content';
    $fckHtml = $editor->Createhtml();
    $this->assign('fckHtml',$fckHtml);
    //分类
    import("App.Model.ProductcategoryModel");
    $Productcategory = D("Productcategory");
    $map['status'] = 1;
    $ProductCategoryList = $Productcategory->order("id desc")->where($map)->findAll(); import('ORG.Util.Tree');
    $tree = new tree($ProductCategoryList);
    $str = "<option value=\$id \$selected>\$spacer \$title</option>";
    $html .= $tree->get_tree(0,$str,0);
    $this->assign('html',$html);
    //
    $this->assign('ProductCategoryRow',$ProductCategoryList);
    $this->assign('ProductRow',$ProductList);
    $this->display();
    }
      

  6.   

    看到两个function的调用方法没,我就纳闷了都。