【发布时间】: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 服务器的配置文件并增加限制。
-
@SvSv 我更想弄清楚是什么导致 PHP 尝试分配 4 GB。
-
@NiettheDarkAbsol 我在这里可能是错的,但与 error_log 所说的内容有关,这是由于我的 index.php 上的第 17 行造成的?
-
使用一些 php 调试器/分析器。