【问题标题】:simple header location not redirecting简单的标头位置不重定向
【发布时间】:2015-06-29 07:33:15
【问题描述】:

下面是一个简单的脚本,用于从工作正常的表中删除信息,但这不会重定向到我需要它去的地方。有任何想法吗?之后我也尝试过使用die(); 等。

<?php
$dbservername = "xxxxx";
$dbusername = "xxxxx";
$dbpassword = "xxxxx";
$conn = mysql_connect($dbservername, $dbusername, $dbpassword);
$db  = mysql_select_db("sxxxxx", $conn);
if (!$conn) { die('Could not connect: ' . mysql_error()); }
?>

<?php
session_start();
include"connect_db.php"; (this include, includes the above connection to db)

$content_id=$_GET['content_id'];
$username=$_SESSION['username'];



$sql = "DELETE FROM `user_blogs` WHERE `id`='".$content_id."' AND `username`='".$username."'";

$res = mysql_query($sql) or die(mysql_error());         

header("location: user_page.php");

?>

【问题讨论】:

  • 出于某种原因,上述评论并未添加到原始评论中(这是 connect_db.php)
  • 我为你修复了代码显示。代码前缺少换行符。

标签: php header location connect


【解决方案1】:

试试这可能是条件问题...

$res = mysql_query($sql) or die(mysql_error());     

if($res){    

header("location: user_page.php");

}else{}

【讨论】:

  • 仍然没有运气......令人沮丧
猜你喜欢
  • 1970-01-01
  • 2016-12-20
  • 2014-01-10
  • 1970-01-01
  • 2015-02-04
  • 2019-05-22
  • 1970-01-01
  • 2017-06-21
  • 2012-10-16
相关资源
最近更新 更多