简体   繁体   English

在我的PHP5服务器上获取似乎是PHP4错误的内容

[英]Getting what appears to be a PHP4 error on my PHP5 server

I'm getting the below error on my server: 我在服务器上收到以下错误:

Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /nfs/c03/h03/mnt/53496/domains/chuggington.com/deploy/releases/20100908062138/system/application/models/home_model.php on line 5

However, the code works in a different part of the server (the development side). 但是,代码在服务器的不同部分(开发侧)工作。 This is me trying to put it live. 这是我试图使之生效。

Below is the code it is referring to: 下面是它所引用的代码:

<?php

class Home_model extends Model {

    public function Home_model()
    {
        // model constructor
        parent::Model();
    }

    function getCode(){
        $ip_address = 'INET_ATON('.$_SERVER['REMOTE_ADDR'].')';
        //echo $_SERVER['REMOTE_ADDR'];
        $this->db->select('country');
        $this->db->order_by('ip', 'desc');
        $query = $this->db->get_where('ip2nation', array('ip <'=>$ip_address), '0,1');
        //print_r($query->row('country'));
        return $query->row('country');
    }
}
?>

Can syslink cause this sort of error? syslink会导致这种错误吗? There are no htaccess scripts interfering either. 也没有htaccess脚本干扰。

Thanks 谢谢

---EDIT--- - -编辑 - -

I have run a phpinfo on the site and it's running php 5.2.6. 我已经在网站上运行了phpinfo,并且正在运行php 5.2.6。 I'll try the addhandler change and see if that works. 我将尝试addhandler更改,看看是否可行。

Just tried the addhandler and i'm still getting the same error. 刚试过addhandler,我仍然遇到相同的错误。

Some hosts may offer both PHP4 and PHP5 environments and require you to choose one or the other, defaulting to PHP4. 有些主机可能同时提供PHP4和PHP5环境,并要求您选择其中之一,默认为PHP4。 Our host requires a AddHandler php5-script .php line in the .htaccess file of directories that should use PHP5. 我们的主机在应该使用PHP5的目录的.htaccess文件中要求AddHandler php5-script .php行。 Others may offer a switch in a control panel. 其他人可能会在控制面板中提供开关。

Consult your host's manual . 请查阅您的房东手册

Remove "public". 删除“公共”。 And put a phpinfo(); 并放一个phpinfo(); on top of that file. 在该文件的顶部。 Find out what's wrong. 找出问题所在。

There's probably an alternative PHP4 interpreter installed, and whatever script accesses your class runs in that context. 可能安装了替代的PHP4解释器,并且任何访问您的类的脚本都在该上下文中运行。

Is there any other code in the same file? 同一文件中是否还有其他代码? This error seems to me like another class or function hasn't been closed properly with a bracket } above. 在我看来,这个错误似乎是另一个类或函数没有用方括号}正确关闭。 Or something of the kind. 或类似的东西。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM