Ir para conteúdo
  • 0

[Resolvido] Php error


Huntedl17

Pergunta

Olá xtibia , recentemente adicionei um sistema de shop no meu site que encontrei aqui no fórum, porém estou tendo alguns problemas referentes a ele como podem ver na imagem abaixo:

 

Spoiler

phperror.thumb.png.1dede93ced60228f98b093c838e8b952.png

 

Se puderem me ajudar agradeço!

Link para o comentário
Compartilhar em outros sites

3 respostass a esta questão

Posts Recomendados

  • 1

Vai na pasta do seu shop, em config/functions.php e troca por esse:

 

<?php

	class shop {
		function connect() {
			$ots = POT::getInstance();
			$ots->connect(POT::DB_MYSQL, connection());
		return $ots->getDBHandle();
		}
		
  function isInstalled() {
  require('config.php');
   $link = mysqli_connect($config['database']['host'], $config['database']['login'], $config['database']['password'], $config['database']['database']);
   $sql = 'SELECT * FROM shop_offer,shop_history';
    $result = mysqli_query($link, $sql) or die(mysqli_error($link));
    return true; 
		}
		
		function points($account) {
			$SQL = $this->connect();
			$points = $SQL->query('SELECT premium_points FROM accounts WHERE name = "'.$account.'"')->fetch();
			return $points['premium_points'];
		}
		
		function getPlayerAccount($name) {
			$SQL = $this->connect();
			$player = $SQL->query('SELECT account_id FROM players WHERE name = "'.$name.'"')->fetch();
			return $SQL->query('SELECT * from accounts WHERE id = '.$player['account_id'].'');
		}
		
		function AddPremium($name,$days) {
			$SQL = $this->connect();
			$account = $this->getPlayerAccount($name)->fetch();
			return $SQL->query('UPDATE accounts SET premdays = (premdays + '.$days.') WHERE name = "'.$account['name'].'"');
		}
		
		function CharacterList($account) {
			$SQL = $this->connect();
			$id = $SQL->query('SELECT id FROM accounts WHERE name = "'.$account.'"')->fetch();
			return $SQL->query('SELECT * FROM players WHERE account_id = '.$id['id'].'');
		}
		
		function isOnline($name) {
			$SQL = $this->connect();
			$player = $SQL->query('SELECT online FROM players WHERE name = "'.$name.'"')->fetch();
			return $player['online'];
		}
		
		
		function isBanned($name) {
			$SQL = $this->connect();
			$ID = $this->getPlayerAccount($name)->fetch();
			return $SQL->query('SELECT * FROM bans WHERE value = '.$ID['id'].'');
		}
		
		function UnBan($name) {
			$SQL = $this->connect();
			$ID = $this->getPlayerAccount($name)->fetch();
			return $SQL->query('DELETE FROM bans WHERE value = '.$ID['id'].'');
		}
		
		function execute_file($file) {
			if (!file_exists($file)) {
			$this->last_error = "The file $file does not exist.";
			return false;
			}
			$str = file_get_contents($file);
			if (!$str) {
			$this->last_error = "Unable to read the contents of $file.";
			return false;
			}

			// split all the queries into an array
			$quote = '';
			$line = '';
			$sql = array();
			$ignoreNextChar = '';
			for ($i = 0; $i < strlen($str); $i++) {
			if ( !$ignoreNextChar ) {
			$char = substr($str, $i, 1);
			$line .= $char;
			if ($char == ';' && $quote == '') {
			$sql[] = $line;
			$line = '';
			} else if ( $char == '\\' ) {
			// Escape char; ignore the next char in the string
			$ignoreNextChar = TRUE;
			} else if ($char == '"' || $char == "'" || $char == '`') {
			if ( $quote == '' ) // Start of a new quoted string; ends with same quote char
			$quote = $char;
			else if ( $char == $quote ) // Current char matches quote char; quoted string ends
			$quote = '';
			}
			}
			else
			$ignoreNextChar = FALSE;
			}

			if ($quote != '') return false;

			foreach ($sql as $query) {
			if (!empty($query)) {
			$r = mysql_query($query);

			if (!$r) {
			$this->last_error = mysql_error();
			return false;
			}
			}
			}
			return true;

		} 
		
		function install() {
			$SQL = $this->connect();
			if ($this->isInstalled())
				return false;
			else
				return $this->execute_file("gifts/config/Shop.sql");
		}
	}
?>

 

Link para o comentário
Compartilhar em outros sites

  • 0
Em 13/12/2017 at 23:58, RED Careless disse:

Vai na pasta do seu shop, em config/functions.php e troca por esse:

 


<?php

	class shop {
		function connect() {
			$ots = POT::getInstance();
			$ots->connect(POT::DB_MYSQL, connection());
		return $ots->getDBHandle();
		}
		
  function isInstalled() {
  require('config.php');
   $link = mysqli_connect($config['database']['host'], $config['database']['login'], $config['database']['password'], $config['database']['database']);
   $sql = 'SELECT * FROM shop_offer,shop_history';
    $result = mysqli_query($link, $sql) or die(mysqli_error($link));
    return true; 
		}
		
		function points($account) {
			$SQL = $this->connect();
			$points = $SQL->query('SELECT premium_points FROM accounts WHERE name = "'.$account.'"')->fetch();
			return $points['premium_points'];
		}
		
		function getPlayerAccount($name) {
			$SQL = $this->connect();
			$player = $SQL->query('SELECT account_id FROM players WHERE name = "'.$name.'"')->fetch();
			return $SQL->query('SELECT * from accounts WHERE id = '.$player['account_id'].'');
		}
		
		function AddPremium($name,$days) {
			$SQL = $this->connect();
			$account = $this->getPlayerAccount($name)->fetch();
			return $SQL->query('UPDATE accounts SET premdays = (premdays + '.$days.') WHERE name = "'.$account['name'].'"');
		}
		
		function CharacterList($account) {
			$SQL = $this->connect();
			$id = $SQL->query('SELECT id FROM accounts WHERE name = "'.$account.'"')->fetch();
			return $SQL->query('SELECT * FROM players WHERE account_id = '.$id['id'].'');
		}
		
		function isOnline($name) {
			$SQL = $this->connect();
			$player = $SQL->query('SELECT online FROM players WHERE name = "'.$name.'"')->fetch();
			return $player['online'];
		}
		
		
		function isBanned($name) {
			$SQL = $this->connect();
			$ID = $this->getPlayerAccount($name)->fetch();
			return $SQL->query('SELECT * FROM bans WHERE value = '.$ID['id'].'');
		}
		
		function UnBan($name) {
			$SQL = $this->connect();
			$ID = $this->getPlayerAccount($name)->fetch();
			return $SQL->query('DELETE FROM bans WHERE value = '.$ID['id'].'');
		}
		
		function execute_file($file) {
			if (!file_exists($file)) {
			$this->last_error = "The file $file does not exist.";
			return false;
			}
			$str = file_get_contents($file);
			if (!$str) {
			$this->last_error = "Unable to read the contents of $file.";
			return false;
			}

			// split all the queries into an array
			$quote = '';
			$line = '';
			$sql = array();
			$ignoreNextChar = '';
			for ($i = 0; $i < strlen($str); $i++) {
			if ( !$ignoreNextChar ) {
			$char = substr($str, $i, 1);
			$line .= $char;
			if ($char == ';' && $quote == '') {
			$sql[] = $line;
			$line = '';
			} else if ( $char == '\\' ) {
			// Escape char; ignore the next char in the string
			$ignoreNextChar = TRUE;
			} else if ($char == '"' || $char == "'" || $char == '`') {
			if ( $quote == '' ) // Start of a new quoted string; ends with same quote char
			$quote = $char;
			else if ( $char == $quote ) // Current char matches quote char; quoted string ends
			$quote = '';
			}
			}
			else
			$ignoreNextChar = FALSE;
			}

			if ($quote != '') return false;

			foreach ($sql as $query) {
			if (!empty($query)) {
			$r = mysql_query($query);

			if (!$r) {
			$this->last_error = mysql_error();
			return false;
			}
			}
			}
			return true;

		} 
		
		function install() {
			$SQL = $this->connect();
			if ($this->isInstalled())
				return false;
			else
				return $this->execute_file("gifts/config/Shop.sql");
		}
	}
?>

 

Nice man, obrigado mais uma vez :D

Link para o comentário
Compartilhar em outros sites

  • 0
A questão neste tópico de suporte foi respondida e/ou o autor do tópico resolveu o problema. Este tópico está fechado e foi movido para Suporte - Resolvidos. Se você tiver outras dúvidas, crie um novo tópico.
Link para o comentário
Compartilhar em outros sites

Visitante
Este tópico está impedido de receber novos posts.
  • Quem Está Navegando   0 membros estão online

    • Nenhum usuário registrado visualizando esta página.
×
×
  • Criar Novo...