GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   PHP help (https://gfy.com/showthread.php?t=1074751)

seeandsee 07-16-2012 04:56 AM

PHP help
 
Quote:

Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 35 bytes) in file.php on line 52
How to fix this, was working fine, but now i get this error? Thanks!

CurrentlySober 07-16-2012 04:58 AM

P.H.P = Pretty Hard Poo...

Need Help?

Take Stool Softener / Laxative

Your Welcome

/thread

seeandsee 07-16-2012 05:02 AM

Quote:

Originally Posted by CurrentlySober (Post 19061500)
P.H.P = Pretty Hard Poo...

Need Help?

Take Stool Softener / Laxative

Your Welcome

/thread


CurrentlySober 07-16-2012 05:05 AM

Quote:

Originally Posted by seeandsee (Post 19061509)

i came.. :thumbsup

Harmon 07-16-2012 05:07 AM

This error message can spring up in a previously functional PHP script when the memory requirements exceed the default 8 MB limit. However, do not fret because this is an easy problem to overcome.


To change the memory limit for one specific script, include a line such as this at the top of the script:

Code:

ini_set("memory_limit","12M");
The 12M sets the limit to 12 megabytes (12582912 bytes). If this does not work, keep increasing the memory limit until your script fits or your server squeals for mercy.

You can also make this a permanent change for all PHP scripts running on the server by adding a line such as this to the server?s php.ini file:

Code:

memory_limit = 12M
Keep in mind that a huge memory limit is a poor substitute for good coding. A poorly written script may inefficiently squander memory which can cause severe problems for frequently executed scripts. However, some applications are run infrequently and require lots of memory like importing and processing a large data file.

notjoe 07-16-2012 05:08 AM

Quote:

Originally Posted by seeandsee (Post 19061499)
How to fix this, was working fine, but now i get this error? Thanks!

Your script is using too much memory. You can either write better code or increase the amount of ram that php is able to consume.

raymor 07-16-2012 05:10 AM

You read the while damn file into memory instead of 1K at a time in a loop. If you DID loop, PHP read the whole damn file into memory anyway because while PHP 5 sucks far less than PHP 4, it still sucks awefully bad. Turn off output buffering.

Because the script is called file.php, I bet the code is the same as every other script with that name. Actually there are two versions of it - one that takes a filename as it's argument, and one that takes a file ID, which is then looked up in a database. If you're passing a filename, a bad guy can pass ../.../cgi-bin/.htpasswd or whatever and get any file they want. Fix that, then fix better because your first try will still leave you vulnerable.

raymor 07-16-2012 05:15 AM

BTW the second thing Harmon said applies in this case. You do not want to increase the memory limit. If you're reading more than 36 MB into RAM at once, you're doing it wrong.


All times are GMT -7. The time now is 04:02 AM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123