从别处移植一个网站,整体报这样的错误
错误一:
Object of class Station could not be converted to string in C:\AppServ\www\lfcha\Module\DAL\DAL_Goods.php on line 737错误二:
Catchable fatal error: Object of class __PHP_Incomplete_Class could not be converted to string in C:\AppServ\www\lfcha\Module\DAL\DAL_Consume.php on line 229基本上都是数据层里的错误,在Google上查说是要下载补丁,但我没找到补丁。把错误一那行代码页贴出来吧
/**
 * 读取站点
 *
 * @param Station $Station
 * @return Station
 */
function GetStation(Station $Station)
{
$sql='Select * from `Station` where 1';
if ($Station->ID!='')
{
$sql.= ' AND `ID`='.$Station->ID;//737行 }
if ($Station->Principal->WebID!='')
{
$sql.= ' AND `Principal`=\''.$Station->Principal->WebID.'\';';
}
$result=mysql_query($sql,ConnMain);
if(mysql_errno(ConnMain))
{
throw new Exception('读取站点失败!');
}
$row=mysql_fetch_array($result);
$NewStation=new Station();
$NewStation->ID=$row['ID'];
$NewStation->Title=$row['Title'];
$NewStation->Principal->WebID=$row['Principal'];
$NewStation->Tel=$row['Tel'];
$NewStation->Address=$row['Address']; return $NewStation;
}

解决方案 »

  1.   

    if ($Station->ID!='')
    {
    $sql.= ' AND `ID`='.$Station->ID;//737行 
    } 这个类有没有 new ,页面头部有没有调用 ? 路径对不对?
      

  2.   

    if ( !empty( $Station->ID ) )   // 这个判断也不对
    {
        $sql.= ' AND `ID`='.$Station->ID;//737行 } 
      

  3.   

    我也遇到过,不过是很变态的
    原来是ftp上传问题。
    最后使用二进制传输解决了,默认是ascii码传输。
      

  4.   


    一般的 ftp 是 二进制上传的
      

  5.   

    本来代码是在我们公司的机器上的,当我拷回来放到我的电脑上后,直接把代码考到了www文件夹下,运行才产生了上述错误我用的appserver,直接服务器和数据库一起装上了
      

  6.   


    这个是没有问题的,你把 $Station 类的相关信息贴出来,最好 是把出错 的那个代码贴全点 ..
      

  7.   

    用的php版本是不是不一样改一个这个试试public function id()
    {
        return $this->$ID;
    }
    //调用的时候改成
    if ( !empty( $Station->id() ) )
    {
        $sql.= ' AND `ID`='.$Station->id();//737行
      

  8.   

    你说有没有可能是appserver的版本问题,并不是一处错误在我的代码里
      

  9.   

    我把代码考到我以前公司同事的机器上时就没有出现这种情况,而是在我的机器上就会出现这种情况,我怀疑是appserver的版本问题,我现在不清楚他用的appserver是什么版本,他也不知道。高手们想想有没有这种可能,以前我们开发这个系统时是一点问题也没有的
      

  10.   

    可能就是php版本问题,你看下你电脑上的 phpinfo.看下 php版本是否和你公司的一样  ..  
      

  11.   

    As of (at least) PHP 5.2, you can no longer convert an object to a string unless it has a __toString method. Converting an object without this method now gives the error:PHP Catchable fatal error:  Object of class <classname> could not be converted to string in <file> on line <line>Try this code to get the same results as before:<?phpif (!is_object($value) || method_exists($value, '__toString')) {
        $string = (string)$value;
    } else {
        $string = 'Object';
    }?> 这是我在Google里搜的,说得是php5.2版本后的会出现这种错误,但是我是修改我的appserv的版本呢,还是修改我的zend studio的版本,我是想不装zend studio,只装appserv在其他人的机器上运行
      

  12.   

    你修改 zend studio 的版本干吗?不要装组合的了, 分开装 php mysql apache  然后选择正确的 php 版本,最好是选择和公司一样的装的时候可以 google 一个,有很多 教你怎么装的 网页
      

  13.   


    public function id()
    {
        return $this->ID; //是这样子的吧
        /*
         .
         .
         .
        */
    }
      

  14.   

    我换了appserv版本后可以使用了,换的是appserv win32 2.56的版本,忘记下载地址了,不然就贴上来。还有就是我遇到一个问题:$_SESSION['UID'] 的值总是变成 "Object id #1" 或是"Object id #10"等等这个问题,网上查了好久,都是看国外的帖子,发现修改下里面的参数("UID")才可以解决这个问题,并不是"UID"这个特殊参数的事情,是其他的也这样,害得我修改了半天,谁有好的办法也可以共享下。结贴了,谢谢phpBoy005 一直的回答,谢谢楼上所有回帖的人