用下面的代码面临的问题:PHP头随机ID变量
<?php
$con = mysql_connect("localhost","","");
if (!$con){
die('Could not connect: ' . mysql_error());
}
mysql_select_db("abc", $con);
$ids = intval($_GET['id']);
if ($ids==0){
$id = rand (0,10);
}
header("Location: http://index.php?id=$id");
?>
浏览器显示出“此页面有太多的重定向”。任何人都请帮我解决这个问题。
那是'index.php'中的代码吗? – Paulpro
你的标题应该是:'header(“Location:/index.php?id=$id”);' –
最后一行绝对缺少URI主机。它应该是http://yourhost.com/index.php?id=$id或者只是index.php?id = $ id,就像@Broken Heart说的那样。 –