某种 MySQL 连接错误,但 table 更新正常?
Some sort of MySQL connection error but the table updates just fine?
太晚了 - 我可能缺少一些非常简单的东西,但我现在无法弄明白。
我的函数:
function likes()
{
global $connection;
$stmt = $connection->prepare("INSERT INTO likes (article_id, ip_address) VALUES (?, ?)");
$stmt->bind_param("is", $_GET['id'], $_SERVER['REMOTE_ADDR']);
$stmt->execute();
$result = $stmt->get_result();
if($result)
{
header("location:javascript://history.go(-1)");
}
else
{
exit('Something weird happened');
}
$stmt-close();
}
函数正在 likePost.php 中调用(../../likes/ 在 http 重写之后)具有以下 link:
<a href='../../likes/" . $post->id . "'><img src='/images/like.png' title='Like this post' alt='Like button' height='32' width='32'></a>
likePost.php中唯一的是
session_start();
include "../db.php";
include "functions.php";
likes();
include "includes/header.php";
在我看来,它应该有效。但是当我点击 link 时,我总是得到一个空白页面,上面写着 "Something weird happened"。但是数据库更新没有问题。
谁能看到我看不到的东西?
我刚发现是 header("location:javascript://history.go(-1)");
造成了问题。我将其更改为 ("Location: /");
并且没有更多问题。所以...我只需要弄清楚如何返回上一页而不是 root...
太晚了 - 我可能缺少一些非常简单的东西,但我现在无法弄明白。
我的函数:
function likes()
{
global $connection;
$stmt = $connection->prepare("INSERT INTO likes (article_id, ip_address) VALUES (?, ?)");
$stmt->bind_param("is", $_GET['id'], $_SERVER['REMOTE_ADDR']);
$stmt->execute();
$result = $stmt->get_result();
if($result)
{
header("location:javascript://history.go(-1)");
}
else
{
exit('Something weird happened');
}
$stmt-close();
}
函数正在 likePost.php 中调用(../../likes/ 在 http 重写之后)具有以下 link:
<a href='../../likes/" . $post->id . "'><img src='/images/like.png' title='Like this post' alt='Like button' height='32' width='32'></a>
likePost.php中唯一的是
session_start();
include "../db.php";
include "functions.php";
likes();
include "includes/header.php";
在我看来,它应该有效。但是当我点击 link 时,我总是得到一个空白页面,上面写着 "Something weird happened"。但是数据库更新没有问题。
谁能看到我看不到的东西?
我刚发现是 header("location:javascript://history.go(-1)");
造成了问题。我将其更改为 ("Location: /");
并且没有更多问题。所以...我只需要弄清楚如何返回上一页而不是 root...