【问题标题】:Allowed memory size of 134217728 bytes exhausted (tried to allocate 4294967296 bytes) Looked at answer? Still not working允许内存大小134217728字节用尽(试图分配4294967296字节) 看了答案?还是行不通
【发布时间】:2017-12-20 14:18:29
【问题描述】:

最近我一直在尝试为我的网站编写一个简单的登录系统,我遇到了很多错误,它似乎在不确定该怎么做。

我收到的错误消息是Allowed memory size of 134217728 bytes exhausted (tried to allocate 4294967296 bytes) on line 17 of index.php 我查看了 stackoverflow 以了解问题的原因可能是什么,并尝试了此处找到的答案

Allowed memory size of 134217728 bytes exhausted (tried to allocate 4294967296 bytes)

但遗憾的是,在 phpmyadmin 中将 longtext 更改为 mediumtext 仍然没有效果,实际上它停止返回任何 error_log 并重新加载了我的网页!如果您前往 beastfox.com,您会看到所有发生的事情都是在输入我添加到数据库中的测试用户名和密码时(用户名:用户名密码:密码)它会导致 HTTP ERROR 500。

我有点不确定该怎么做,因为它显然与我的 index.php 有关我已经列出了如下所示的代码,

<?php
   include("database.php");
   session_start();

   if($_SERVER["REQUEST_METHOD"] == "POST") {
      // Create querystring
      $sql = "SELECT password FROM admin WHERE username = ?";

      // Prepare, bind, execute
       if (!$stmt = mysqli_prepare($mysqli,$sql)) {
    echo "Failed to prepare:".mysqli_error($mysqli);
    return;
}
      $stmt = mysqli_prepare($mysqli,$sql);
      mysqli_stmt_bind_param($stmt, 's', $_POST['username']);
      mysqli_stmt_execute($stmt);
      mysqli_stmt_bind_result($stmt, $user_password);
      if (mysqli_stmt_fetch($stmt)) {
         // Validate password
         if (password_verify($_POST['password'], $user_password)) {
             session_register("username");
             $_SESSION['login_user'] = $username;

             header("location: myaccount.php");
            exit;
         } else {
             $error = "Your Login Name or Password is invalid";
         }
      mysqli_stmt_close($stmt);
      } else {
         $error = "Your Login Name or Password is invalid";
      }
   }
?>

根据error_log,它说是由于第17行 (mysqli_stmt_bind_result($stmt, $user_password);)

就像其他人在这里堆栈溢出一样,我将列出我的版本等

PHP 版本:5.6

libmysql - 5.1.73:

memory_limit:168M

如果您认为自己对问题所在有任何想法,我们非常感谢!

如果还需要什么,我会诚实地尝试任何事情,

我会继续寻找以防万一,但目前我尝试的所有方法似乎都不起作用。

【问题讨论】:

标签: php mysql


【解决方案1】:

正如stated in your linked question 一样,问题在于为TEXT 列绑定结果变量。

您的密码哈希不需要TEXT 列,足够的VARCHAR(255) 列就足够了。将您的密码哈希列更改为该类型。

【讨论】:

  • 非常感谢!这样做的唯一问题(我已经尝试过类似的方法)是这样做之后在我的 ftp 中没有返回 error_log,它所做的只是重新加载页面(或做某事)但是单击提交后没有创建 error_log。
猜你喜欢
  • 2013-08-09
  • 2018-12-11
  • 2016-04-18
  • 2021-12-29
  • 2017-07-23
  • 2018-02-23
  • 2014-11-20
  • 2017-10-30
  • 1970-01-01
相关资源
最近更新 更多