hobbes Posted October 14, 2008 Posted October 14, 2008 Looks like I've finally hit my allowed limit on my server. Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 19456 bytes) If I remove a pre-existing php script on my server, will this allow room for other php scripts to be used or is it all cached? Other words, what are my options other than switching to a semi/dedicated server. Quote
Floydian Posted October 14, 2008 Posted October 14, 2008 Re: PHP Memory Limit It sounds like the script that encountered that error needs a little optimization. As far as I know, that sort of error is encountered when one script exceeds the memory limit, not when all users accessing a php script combined exceed it. ;) The cause of the error is most likely a for loop, while loop, or some other sort of loop that has run amuck. Quote
hobbes Posted October 14, 2008 Author Posted October 14, 2008 Re: PHP Memory Limit Aah, ok, that makes more sense. And yes, there is a foreach loop. I'm not quite sure if your familiar with mc's car mod script, but it only affects the tune.php script. I would post the foreach loop for evaluation, but am not sure what the rules are when posting parts of a paid modification? Quote
Floydian Posted October 14, 2008 Posted October 14, 2008 Re: PHP Memory Limit I'm not sure either. You're probably okay posting just the portion of the code starting and ending with the foreach loop (possibly) But since it's a paid mod, does the person not support the script? Quote
hobbes Posted October 14, 2008 Author Posted October 14, 2008 Re: PHP Memory Limit Very true Floydian, and I would really love to. The only thing is, Dabomstew hasn't been online here for over a year. :wink: I also wanted to correct a mistype in my previous post, its with carmadd.php and not through a for loop, it's a SQL query that is giving me that error. That being said, I have no problems in sharig this quote from the script with the rest of you. $q=mysql_query("SELECT iv.*,i.* FROM cars_playercars iv LEFT JOIN cars_types i ON iv.cpcCAR=i.carID WHERE cpcID={$_GET['ID']} and cpcPLAYER=$userid",$c); I have also tried $q=mysql_query("SELECT `cpcID` FROM `cars_playercars` WHERE `cpcID` = {$_GET['ID']} and `cpcPLAYER` = $userid",$c); and the exact same message. The SQL tables are generic just like any other and I don't understand how I am getting this Fatal Error. Quote
Floydian Posted October 14, 2008 Posted October 14, 2008 Re: PHP Memory Limit Try taking the query, and running it manually (i.e., php myadmin, mysql command line, or some other mysql application). This is your query string. You just need to fill in the variables. If you don't know the values, echo this string: "SELECT iv.*,i.* FROM cars_playercars iv LEFT JOIN cars_types i ON iv.cpcCAR=i.carID WHERE cpcID={$_GET['ID']} and cpcPLAYER=$userid" or echo it: echo "SELECT iv.*,i.* FROM cars_playercars iv LEFT JOIN cars_types i ON iv.cpcCAR=i.carID WHERE cpcID={$_GET['ID']} and cpcPLAYER=$userid" See what that does when you run it manually. Quote
hobbes Posted October 15, 2008 Author Posted October 15, 2008 Re: PHP Memory Limit No issues there. I changed the cpcID and cpcPlayer value to one in the database and received a normal query result. cpcID cpcPLAYER cpcCAR cpcACCLV cpcHANLV cpcSPDLV cpcSHDLV carID carNAME carDESC carCOST carACC carHAN carSPD carSHD carBUYABLE 1 166 1 1 1 1 1 1 Mini Roxi The Mini Roxi is a very compact car. It is not des... 3000 2 2 2 2 1 Quote
Floydian Posted October 15, 2008 Posted October 15, 2008 Re: PHP Memory Limit You might want to contact your web host to see if you can get them to increase the max memory usage limit set for php in the php ini file. Quote
mdshare Posted October 15, 2008 Posted October 15, 2008 Re: PHP Memory Limit normally you can create a php.ini file and put it your web root and it should use your settings compared to the webhosts standard settings. possible ways create a php.ini and ad following line adjust 12M if needed to higher memory_limit = 12M or through htaccess add php_value memory_limit 12M again adjust/increase memory value as needed if these don't work contact your webhost as proposed by floydian Quote
hobbes Posted October 15, 2008 Author Posted October 15, 2008 Re: PHP Memory Limit Thanks for your responses. I have tried changing the memory_limit higher among other things. Only the server admin can change it and they told me that it's restricted to 32mb and that the only option i have is to switch hosts. A real shame as this is the only script that has given me this headache. Quote
Cronus Posted October 15, 2008 Posted October 15, 2008 Re: PHP Memory Limit How is this one query doing so much damage. Isn't there an easier way you could just work the script so it would function without all this trouble? Quote
mdshare Posted October 15, 2008 Posted October 15, 2008 Re: PHP Memory Limit hmmm if you are on a VPS you should have minimum 512Mb available now corrupted tables can also give issues maybe try a repair/optimize on your mysql db Quote
Floydian Posted October 15, 2008 Posted October 15, 2008 Re: PHP Memory Limit I still think it has something to do with a loop. I don't know how long that script is, but I've got scripts that span 3 to 5 thousand lines of code, and crons that can take more than 30 seconds to execute. But it's only when I get a loop that has run amuck that I get a memory error like that. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.