gpt4 book ai didi

php - 解析错误 : syntax error, unexpected T_ELSE, expecting T_FUNCTION in/home/petit/public_html/system/database/mysqli.php on line 54

转载 作者:行者123 更新时间:2023-12-01 11:03:47 28 4
gpt4 key购买 nike

我已经将 opencart 从一个服务器传输到另一个服务器,但出现以下错误解析错误:语法错误,意外的 T_ELSE,期待 T_FUNCTION in/home/petit/public_html/system/database/mysqli.php on line 54

当我尝试访问我的站点或我的管理员页面时。知道为什么会这样吗?我已经一步一步地按照程序进行了。

这是 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();
}
}
?>

提前谢谢你

最佳答案

else没有ifif block 被关闭。这样做 -

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();
}

关于php - 解析错误 : syntax error, unexpected T_ELSE, expecting T_FUNCTION in/home/petit/public_html/system/database/mysqli.php on line 54,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26713062/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com