2014-11-03 85 views
2

我做了一个opencart从服务器转移到另一个,我得到以下错误 解析错误:语法错误,意想不到的T_ELSE,上线54解析错误:语法错误,意外的T_ELSE,期望在第54行的/home/petit/public_html/system/database/mysqli.php T_FUNCTION

在/home/petit/public_html/system/database/mysqli.php期待T_FUNCTION当我尝试访问我的网站或我的管理员页面。 任何想法为什么发生这种情况? 我已经按照程序一步一步来。

这是mysqli.php

<?php 
final class MySQLi { 
    private $mysqli; 

    public function __construct($hostname, $username, $password, $database) { 
     $this->mysqli = new mysqli($hostname, $username, $password, $database); 

     if ($this->mysqli->connect_error) { 
      trigger_error('Error: Could not make a database link (' . $this->mysqli->connect_errno . ') ' . $this->mysqli->connect_error); 
     } 

     $this->mysqli->query("SET NAMES 'utf8'"); 
     $this->mysqli->query("SET CHARACTER SET utf8"); 
     $this->mysqli->query("SET CHARACTER_SET_CONNECTION=utf8"); 
     $this->mysqli->query("SET SQL_MODE = ''"); 
    } 

    public function query($sql) { 
     $result = $this->mysqli->query($sql); 



     if ($this->mysqli->errno) { 
     //$mysqli->errno 
     } 

      if (is_resource($resource)) { 
       $i = 0; 

       $data = array(); 

       while ($row = $result->fetch_object()) { 
        $data[$i] = $row; 

        $i++; 
       } 

       $result->close(); 

       $query = new stdClass(); 
       $query->row = isset($data[0]) ? $data[0] : array(); 
       $query->rows = $data; 
       $query->num_rows = $result->num_rows; 

       unset($data); 




       return $query; 
      } else { 
       return true; 
      } 
     } else { 
      trigger_error('Error: ' . mysql_error($this->link) . '<br />Error No: ' . mysql_errno($this->link) . '<br />' . $sql); 
      exit(); 
     } 
    } 

    public function escape($value) { 
     return $this->mysqli->real_escape_string($value); 
    } 

    public function countAffected() { 
     return $this->mysqli->affected_rows; 
    } 

    public function getLastId() { 
     return $this->mysqli->insert_id; 
    } 

    public function __destruct() { 
     $this->mysqli->close(); 
    } 
} 
?> 

预先感谢您

+0

使用IDE来匹配'{'curly'''大括号,使用不同的缩进样式。 – mario 2014-11-03 11:18:17

+0

查看'sgt'的答案 – Naincy 2014-11-03 11:27:22

回答

9

else没有ifif块已关闭。这样做 -

if ($this->mysqli->errno) { 
//$mysqli->errno 

    if (is_resource($resource)) { 
     $i = 0; 

     $data = array(); 

     while ($row = $result->fetch_object()) { 
      $data[$i] = $row; 

      $i++; 
     } 

     $result->close(); 

     $query = new stdClass(); 
     $query->row = isset($data[0]) ? $data[0] : array(); 
     $query->rows = $data; 
     $query->num_rows = $result->num_rows; 

     unset($data); 




     return $query; 
    } else { 
     return true; 
    } 
} else { 
    trigger_error('Error: ' . mysql_error($this->link) . '<br />Error No: ' . mysql_errno($this->link) . '<br />' . $sql); 
    exit(); 
} 
+0

非常感谢你 – falcongr 2014-11-04 12:24:35

+0

欢迎...并且如果解决了,请接受答案。 – 2014-11-04 12:25:45

相关问题