Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Fatal error: Allowed memory size of 134217728 bytes exhauste

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Installation and Setup
View previous topic :: View next topic  
Author Message
edduvs
Smarty Rookie


Joined: 27 Jun 2011
Posts: 10

PostPosted: Tue Jul 05, 2011 7:52 pm    Post subject: Fatal error: Allowed memory size of 134217728 bytes exhauste Reply with quote

Hi there again, my problem resums at the SmartyPaginate.class.php

First when i installed the script, i needed to make all functions beside the cunstructor in the SmartyPaginate class public statics, because i needed to make a static call on a nonstatic function. Anyway, thats solved now, after that, no errors got in my way, but this error came in.

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 35 bytes) in C:\xampp\htdocs\actions\ally_in_ally_members.php on line 11

Code:

<?php
   global $tpl;

   session_start();
    include('inc/libs/SmartyPaginate.class.php');
   
   function get_db_results() {
      global $user;
      $lista = array();
      $sql = db('query','SELECT id,username,ally_found FROM users WHERE ally = '.$user['ally'].' ORDER BY points DESC');
      while($sql) $lista[] = $sql;
      SmartyPaginate::setTotal(count($lista));
        return array_slice($lista, SmartyPaginate::getCurrentIndex(),
      SmartyPaginate::getLimit());
    }
   
   SmartyPaginate::connect();
    SmartyPaginate::setLimit(20);
   SmartyPaginate::setLastText('LAST');
   SmartyPaginate::setFirstText('FIRST');
    $tpl->assign('results', get_db_results());
    SmartyPaginate::assign($tpl);
   
   $tpl->display('game_ally_in_ally_members.tpl');
?>


What's wrong with this one ?
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Tue Jul 05, 2011 8:17 pm    Post subject: Reply with quote

You need to apply the index/limit to your SQL query. You are selecting everything and filling memory.
Back to top
View user's profile Send private message Visit poster's website
edduvs
Smarty Rookie


Joined: 27 Jun 2011
Posts: 10

PostPosted: Wed Jul 06, 2011 2:47 pm    Post subject: Reply with quote

Damn, didn't see that i didn't add global $user to the first global setter.
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Installation and Setup All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP