提问者:小点点

php上的mysqli内存不足(256KB???)


我试图通过PHP在MySQL数据库上执行SELECT语句。 当我执行脚本时,会出现一个致命错误:

致命错误:允许的内存大小262144字节耗尽(尝试分配94020字节)

256KB对每个人来说都不够,是吗? 如何调整这个限额?

问候

克里斯

我的代码是:

ini_set('memory_limit', '1024MB');
  ...  
  // Create connection
  $mySQLConn = new mysqli($servername, $username, $password, $database);

  if ($mySQLConn->connect_error) {
    throw new Exception('Kann nicht auf DB verbinden: ' . $mySQLConn->connect_error);
  }
 
  
  $result = $mySQLConn->real_query("SELECT * FROM artikel;");
  $result = $mySQLConn->store_result(); // <- here I get this fatal error

共1个答案

匿名用户

https://www.php.net/manual/en/faq.using.php#faq.using.shorthandbytes说:

有哪些可用的速记字节选项?

可用的选项是K(用于千字节),M(用于兆字节)和G(用于千兆字节;从PHP 5.1.0开始可用),并且都不区分大小写。 其他任何东西都假定为字节。 1M等于一兆字节或1048576字节。

不要使用1024MB。 请使用1024M