php - XAMPP 服务器错误(错误 500)

标签 php html mysql apache xampp

The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there was an error in a CGI script. If you think this is a server error, please contact the webmaster. Error 500 localhost Apache/2.4.25 (Win32) OpenSSL/1.0.2j PHP/5.6.30

我打开日志错误,发现问题出在我的 user.inc.php 中的 header():

function getLogin($conn){
if(isset($_POST['login']))
{
    $uid=$_POST['uid'];
    $pwd=$_POST['pwd'];

    $sql= "SELECT * FROM user WHERE uid='$uid' AND pwd ='$pwd'";
    $result=$conn->query($sql);
    if (mysqli_num_rows($result) == 1){
        if($row = $result->fetch_assoc()){

                $_SESSION['id'] = $row['id'];
                header("Location : index.php?loginsuccess");
                exit();
        }
    }
    else{



    }
}
}

错误日志:

[Tue Jul 25 10:26:58.464402 2017] [http:error] [pid 2380:tid 1656] [client ::1:49602] AH02429: Response header name 'Location ' contains invalid characters, aborting request, referer: http://localhost/tgss/index.php

请帮忙。

最佳答案

改变这个

header("Location : index.php?loginsuccess");

对此

header("Location: index.php?loginsuccess");

错误来自 Location 和冒号 ( : ) 之间的空格。

我测试了你的 header("Location : index.php?loginsuccess"); 在冒号 ( : ) 之间有空格,它还返回一个 错误 500

关于php - XAMPP 服务器错误(错误 500),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45293050/

相关文章:

php - X-FRAME-OPTIONS 显示两次,X-XSS-PROTECTION 显示错误

php - 在python中压缩base64字符串并在PHP中提取它

Javascript : Return . innerHTML 作为语法

php - XSS 过滤输出...可以吗?

c# - 无需在客户端安装 mysql 连接器即可将应用程序转换为工作

php - 如何根据 Eloquent 已有的图像 id 获取图像信息?

javascript - 使用 jQuery 获取跨度内的特定文本

JQuery 隐藏前 3 个 div 元素

php - 使用 php 和 mysql 选择、更新记录

php - Laravel 5.5 获取最近更新的多条记录