Page 1 of 1

Fatal Error when openning the PHP file [solved]

Posted: Wed Jun 21, 2006 11:19 pm
by technofreak
Hi,

when i try to open my file login.php in the browser using the url "http;//localhost/login.php" the following fatal error gets displayed. what to do ?

Code: Select all

Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 8192 bytes) in /var/www/login.php on line 1
How do i allocate more memory. Earlier everything was working fine with my previous files :(

Posted: Wed Jun 21, 2006 11:21 pm
by olegkikin
8388608 is probably the limit set by your server. Change it.

Posted: Wed Jun 21, 2006 11:27 pm
by technofreak
My php.ini file shows this

Code: Select all

memory_limit = 8M      ; Maximum amount of memory a script may consume (8MB)
my login.php file is 294bytes and there are totally 4 files of similar size. Why does then such an error occurs when I have 8MB of size allocated for the script ?

Posted: Wed Jun 21, 2006 11:30 pm
by feyd
that's 8MB of memory for the script and all it's variables, including those that come from a database, files, external pages, etc etc.

Posted: Wed Jun 21, 2006 11:31 pm
by Benjamin
Are there any for or while loops in it? Post the login.php code.

Posted: Wed Jun 21, 2006 11:32 pm
by Benjamin
feyd wrote:that's 8MB of memory for the script and all it's variables, including those that come from a database, files, external pages, etc etc.
Maybe your loading the entire database into memory?

Posted: Wed Jun 21, 2006 11:35 pm
by technofreak
Here is my login.php

Code: Select all

<?php 

session_start(); 

include("login.php");

page_header("login.php", "tenmiles.gif", "TenMiles Corporation", "Login Page");

include("navig.php"); ?>

<div><table>
<tr><td>
<?php include("login_script.php"); ?>
</td></tr>
</table></div>

<?php

include("footer.php");
page_footer("");

?>
The size of include files are ... header.php --> 250 Bytes, footer.php --> 201 Bytes and login_script.php --> 2.5 KB.

It doesnot contain any loops, it has one mysql query for the login verification of username and passowrd.

Posted: Wed Jun 21, 2006 11:39 pm
by Benjamin

Code: Select all

include("login.php");
That is your problem, the file is including itself, hence a loop.

Posted: Wed Jun 21, 2006 11:39 pm
by technofreak
My code will fetch data from the databse only if the form being displayed is filled up and the submit button is filled. This error is shown before the form being displayed. So, it can't be a problem of database ? Also, only one row of data is got from the databse, will it occupy 8MB of space.

My previous codes where much bigger than this, and it was working fine with it.

Posted: Wed Jun 21, 2006 11:39 pm
by olegkikin
It's not the size of your PHP files. It's how much memory they use. PHP is very greedy with memory. I had scripts that used 5 GB (not MB) of RAM. (I had to rewrite them in C++ actually, because it was getting crazy).


and remove this, it's an infinite loop

include("login.php");

Posted: Wed Jun 21, 2006 11:41 pm
by technofreak
astions wrote:

Code: Select all

include("login.php");
That is your problem, the file is including itself, hence a loop.
thanks a lot, such a silly mistake... proly i have to increase the sharpness of my vision much more :D

its "header.php' instead :)