0
I’m getting this mistake:
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
When I run these scripts:
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);
}
}
php characters.
<?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;
}
}
I’ve done everything but can’t solve the problem, a quick search, some cases managed to solve by adding this line of code:
ini_set('memory_limit','-1');
With me it did not work, what is the solution to this problem?
I got with me, that, man loop
is out of control.
You are calling the function
fetch
all the time, change the$this
forparent
, was to call the Connect class right?– fernandoandrade
@fernandoandrade is not necessary. With more time I explain why.
– Guilherme SpinXO
My mistake is necessary yes, sorry.
– Guilherme SpinXO