Results 1 to 3 of 3

Thread: Fatal Error with allocated memory size :-S

  1. #1

    Thread Starter
    Addicted Member BIOSTALL's Avatar
    Join Date
    Apr 2005
    Location
    Northampton, UK
    Posts
    180

    Fatal Error with allocated memory size :-S

    Hi all, i am adding the ability to attach images to posts on my forum but i'm getting the error:

    Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 129 bytes) in /home/virtual/site13/fst/var/www/html/ForumNewReply.php on line 88

    All i'm doing is passing the attached images filenames to ForumNewReply.php and displaying them.

    This is the code where the error is happening:
    Code:
    $_SESSION['currentfiles'] = $_SESSION['currentfiles']."c~c~c".$iname; 
            $exploded = explode("c~c~c", $_SESSION['currentfiles']); 
            $inarray = count($exploded)-1; 
                for ($i=0; $i=$exploded[$inarray]; $i+=1) { 
                    $attachedfiles .= "<li>".$exploded[$i]."</li>";     
                }
    Can i not have any suggestions to increase php.ini memory_limit as the page is used very regularly. I've tried increasing it a bit but i dont see why just displaying an array full of filenames should cause an error :-S

    Thanks, BIOSTALL

  2. #2
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: Fatal Error with allocated memory size :-S

    If you are using your memory limit of 8MB then you need to seriously consider the size of the variables your script is allocating.

    Do you create and large database cursors? Store large files in strings or have several million variables?
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  3. #3

    Thread Starter
    Addicted Member BIOSTALL's Avatar
    Join Date
    Apr 2005
    Location
    Northampton, UK
    Posts
    180

    Re: Fatal Error with allocated memory size :-S

    Actually.. stuff that... i found out what i was doing wrong.. What i have now is this:
    Code:
    if ($_GET['imagename']!="") {
    	$iname = $_GET['imagename'];
    	if (!isset($_SESSION['currentfiles'])) {
    		$_SESSION['currentfiles'] = $iname;
    		$attachedfiles = $iname;
    	}else{
    		$iname=",".$iname;
    		$_SESSION['currentfiles'] += $iname;
    		$exploded = explode(",", $_SESSION['currentfiles']);
    		$inarray = count($exploded);
    			for ($i=0; $i<count($exploded); $i++) {
    				$attachedfiles .= "<li>".$exploded[$i]."</li>";
    			}
    	}
    	echo "$iname<br>";
    	echo $_SESSION['currentfiles']."<br>";
    	echo "$exploded<br>";
    	echo "$inarray<br>";
    	unset($inarray, $exploded);
    	$attachmessage = "<b>Images currently attached:</b><br><br> <i>".$attachedfiles."</i><br>";
    }
    As you can see i'm echoing the variables and this is what its giving me:

    $iname - ,picture.gif
    $_SESSION['currentfiles'] - 96846981
    $exploded - Array
    $inarray - 1

    As you can see, when i echo my session variable, its giving me a long integer and i can't figure out why... when i echo the session variable it should be two or more filenames seperated by a comma.

    Anyone help please??

    Many Thanks, BIOSTALL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width