Estou obtendo este erro:
Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 1640 bytes) in C:\AppServ\www\muweb\class\Connect.php on line 31
Quando executo esses script:
index.php
<?php
require_once 'settings/Config.php';
require_once 'class/Connect.php';
require_once 'class/Characters.php';
$char = new Characters;
?>
<!DOCTYPE html>
<html>
<head>
<title>SELECT</title>
</head>
<body>
<table>
<thead>
<tr>
<th>Conta ID</th>
<th>Personagem</th>
<th>Dinheiro</th>
</tr>
</thead>
<tbody>
<?php
while ($get = $char->fetch()):
?>
<tr>
<td><?php echo $get['AccountID']; ?></td>
<td><?php echo $get['Name']; ?></td>
<td><?php echo $get['Money']; ?></td>
</tr>
<?php endwhile; ?>
</tbody>
</table>
</body>
</html>
Connect.php
<?php
class Connect {
private $_cn;
private $_db;
public function __construct() {
$this->Connection();
$this->Database();
}
private function Connection() {
$this->_cn = mssql_connect(HOST, USER, PASS);
if ($this->_cn == false) {
die('Connection error!');
}
}
private function Database() {
$this->_db = mssql_select_db(BASE, $this->_cn);
if ($this->_db == false) {
die('Select database error!');
}
}
public function execute($query) {
$execute = mssql_query($query);
if ($execute == false) {
die('Execute error:' . $query);
} else {
return $execute;
}
}
public function row($query) {
return mssql_fetch_row($query);
}
public function fetch($query) {
return mssql_fetch_array($query);
}
public function num($query) {
return mssql_num_rows($query);
}
}
characters.php
<?php
class Characters extends Connect {
public function fetch() {
$fetch = $this->fetch($this->execute("SELECT * FROM Character WHERE AccountID = 'guialves95'"));
return $fetch;
}
public function num() {
$num = $this->num($this->execute("SELECT * FROM Character WHERE AccountID = 'guialves95'"));
return $num;
}
}
Já fiz de tudo mas não consigo solucionar o problema, uma rápida pesquisa, alguns casos conseguiram solucionar adicionando está linha de código:
ini_set('memory_limit','-1');
Comigo não deu certo, qual a solução para este problema?
Tenho comigo, que, meu loop
está fora de controle.
fetch
toda hora, troca o$this
porparent
, era para chamar a da classe Connect certo?