标题已由php ERROR发送:|

时间:2016-07-17 00:13:07

标签: php html redirect header location

我在php上遇到以下代码问题:(

<?php echo $_GET["u"]; 
$servername = "localhost";
$username = "******";
$password = "*****?";
$dbname = "*****";

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
} 
$tt=$_GET["u"];
$sql = "SELECT url from code WHERE BINARY short="."'$tt'";
$result=$conn->query($sql);
$data=$result->fetch_assoc();
$url="Location: ".$data["url"];
header($url); /* Redirect browser */
exit();
?>

我在这一行的问题:(

 header($url); /* Redirect browser */

$ url变量是从数据库获取的链接。!

1 个答案:

答案 0 :(得分:1)

嗯,它没有撒谎。您的脚本顶部有echo $_GET["u"];

在发送标题之前必须没有输出。