Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

sanjayacloud's avatar

500 Error PHP Fatal error: Allowed memory size of 134217728 bytes exhausted

Hello Everyone,

I have got a 500 error with "PHP Fatal error: Allowed memory size of 134217728 bytes exhausted"

This my code.

 public function index()
    {
        $result = DB::select("select
    wp_posts.ID ,
    wp_posts.post_date,
    wp_posts.post_status,
     wp_woocommerce_order_items.order_item_id,
     wp_woocommerce_order_items.order_id,
      wp_woocommerce_order_items.order_item_name,
      wp_woocommerce_order_itemmeta.meta_key,
      wp_woocommerce_order_itemmeta.order_item_id
from
    wp_posts,
    wp_postmeta,
    wp_woocommerce_order_items,
    wp_woocommerce_order_itemmeta
where
    post_type = 'shop_order' and
    wp_posts.ID = wp_postmeta.post_id");
//        $result = Wp_post::where('post_type' , 'shop_order')->get();
        return view('admin.lesson.manage')->with('data',$result )->render();
    }
``

This Query is work properly in phpmyadmin. 

Any  one have idea about this.. 
0 likes
3 replies
Yapiyo's avatar

This sound like a PHP configuration limit. I suggest you look at the PHP ini setting: "memory_limit". If you can't access this try: ini_set('memory_limit', '256MB'); at the start of your application.

It is possible the this value us protected for rewrite. if this is the case try contacting your webhost.

Yapiyo's avatar

@sanjayacloud I just noticed username. It's an account from work created by my colleague. Updated it to something a bit more personal XD.

Did the code work? it is possible the script even exceeds the 256MB. Just remembered you can use the "phpinfo()" to check if the value is overwritten. Hope is helps

Please or to participate in this conversation.