0

after the session values are loaded from database, the header redirect below is giving error ?

while($row=mysql_fetch_row($res))
{
            $_SESSION['id']=$row[0];
            $_SESSION['name']=$row[1];
            $_SESSION['rollno']=$row[2];
            $_SESSION['pass']=$row[3];
            $_SESSION['email']=$row[4];
            $_SESSION['secans']=$row[5];
            $_SESSION['mob']=$row[6];     
            header("location:index.php");
 }

the error on the check.php page

headers already sent by (output started at /home/name/public_html/fest/header.php:19) in /home/name/public_html/fest/check.php on line 40 (line 40:  header("location:index.php"); )
4

1 回答 1

1

是在header()里面while loop。将while循环放在header()外面。

它应该如下所示:

while($row=mysql_fetch_row($res))
{
            $_SESSION['id']=$row[0];
            $_SESSION['name']=$row[1];
            $_SESSION['rollno']=$row[2];
            $_SESSION['pass']=$row[3];
            $_SESSION['email']=$row[4];
            $_SESSION['secans']=$row[5];
            $_SESSION['mob']=$row[6];     

 }

          header("location:index.php");
于 2013-04-26T07:33:53.917 回答