Fatal Error when openning the PHP file [solved]

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
technofreak
Forum Commoner
Posts: 74
Joined: Thu Jun 01, 2006 12:30 am
Location: Chennai, India
Contact:

Fatal Error when openning the PHP file [solved]

Post 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 :(
Last edited by technofreak on Wed Jun 21, 2006 11:47 pm, edited 1 time in total.
olegkikin
Forum Newbie
Posts: 12
Joined: Wed Jun 21, 2006 10:01 pm

Post by olegkikin »

8388608 is probably the limit set by your server. Change it.
User avatar
technofreak
Forum Commoner
Posts: 74
Joined: Thu Jun 01, 2006 12:30 am
Location: Chennai, India
Contact:

Post 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 ?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Post by Benjamin »

Are there any for or while loops in it? Post the login.php code.
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Post 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?
User avatar
technofreak
Forum Commoner
Posts: 74
Joined: Thu Jun 01, 2006 12:30 am
Location: Chennai, India
Contact:

Post 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.
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Post by Benjamin »

Code: Select all

include("login.php");
That is your problem, the file is including itself, hence a loop.
User avatar
technofreak
Forum Commoner
Posts: 74
Joined: Thu Jun 01, 2006 12:30 am
Location: Chennai, India
Contact:

Post 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.
olegkikin
Forum Newbie
Posts: 12
Joined: Wed Jun 21, 2006 10:01 pm

Post 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");
User avatar
technofreak
Forum Commoner
Posts: 74
Joined: Thu Jun 01, 2006 12:30 am
Location: Chennai, India
Contact:

Post 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 :)
Post Reply