Jump to content

Recommended Posts

Добрый день!

 

Очень нужна помощь. при переносе с денвера на хостинг появляется ошибка в php (


Parse error: syntax error, unexpected 'else' (T_ELSE), expecting function (T_FUNCTION) in /home/opencart/opencart.nichost.ru/docs/system/database/mysqli.php on line 54)

 

сама строка вот (   else {

trigger_error('Error: ' . mysql_error($this->link) . '<br />Error No: ' . mysql_errno($this->link) . '<br />' . $sql);
exit();

}   )

 

Я думаю это актуальная ошибка. В config.conf сменил с mysql -> mysqli 

Очень нужна ваша помощь

Share this post


Link to post
Share on other sites

А перед else есть скобка } ?

Отправлено с моего Lenovo K50-t5 через Tapatalk

Share this post


Link to post
Share on other sites

У Вас скорее всего еще одна } должна быть перед else...покажите весь файл, заверните <code>

Share this post


Link to post
Share on other sites

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) . '
Error No: ' . mysql_errno($this->link) . '
' . $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();
}
}
?>

Share this post


Link to post
Share on other sites

В следующем куске кода

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

Вот этот else

} else {
trigger_error('Error: ' . mysql_error($this->link) . '

Ни к чему не относится, нету if для него, попробуйте убрать вот это

return true;
}
} else {

Share this post


Link to post
Share on other sites

Fatal error: Cannot redeclare class MySQLI in /home/opencart/opencart.nichost.ru/docs/system/database/mysqli.php on line 2

 

<?php

final class MySQLi {
private $mysqli;
 
так получилось

Share this post


Link to post
Share on other sites

ТС, вернитесь на mysql. "mysql deprecated" все же лучше, чем fatal или parse error.

 

Альтернативу см. тут

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
You are posting as a guest. If you have an account, please sign in.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×

Important Information

On our site, cookies are used and personal data is processed to improve the user interface. To find out what and what personal data we are processing, please go to the link. If you click "I agree," it means that you understand and accept all the conditions specified in this Privacy Notice.