www.webdeveloper.com
Results 1 to 7 of 7

Thread: Warning: Header may not contain more than a single header

  1. #1
    Join Date
    May 2014
    Posts
    26

    Warning: Header may not contain more than a single header

    Hi there,

    i have recieved this notice

    Warning: Header may not contain more than a single header, new line detected in C:\xampp\htdocs\a\Student_Edit_Handler.php on line 53

    and these are my codes. Kindly help me to fix this.

    PHP Code:
    <?php
        session_start
    ();
        
    $session_id $_SESSION['user_id'];
        if(
    $session_id == null){
           
    header("location:Student_Edit.php");
           die();
        }
        include 
    'Connect.php';
        
    $flag "success";
        function 
    rollbackData(){
            
    mysql_query(" ROLLBACK ");
            global 
    $flag
            
    $flag "error";
            if(
    mysql_error() != null){
                die(
    mysql_error());
            }
        }
        
    $student_id $_POST['student_id'];
        
    $first_name $_POST['first_name'];
        
    $last_name $_POST['last_name'];
        
    $gender $_POST['gender'];
        
    $date_of_birth date("Y-m-d",strtotime($_POST['date_of_birth']));
        
    $contact_no $_POST['contact_no'];
        
    $grade $_POST['grade'];
        
    $section $_POST['section'];
        
    $LRN $_POST['LRN'];
        
    $email1 $_POST['email1'];
        
    $email2 $_POST['email2'];
        
    $address $_POST['address'];
        
    $description $_POST['description'];
        
    $imagename "";
        
    $flag"";
            
    mysql_query("SET AUTOCOMMIT = 0 ");
            if(
    mysql_error() != null){
                die(
    mysql_error());
            }
        
    $query "UPDATE student_information SET first_name='$first_name',last_name='$last_name',";    
        
    $query .= "gender='$gender',date_of_birth='$date_of_birth',contact_no='$contact_no',grade='$grade',section='$section',";
        
    $query .= "LRN='$LRN',email1='$email1',email2='$email2',address='$address',description='$description'";     
        
    $query .= " WHERE student_id='{$_SESSION['user_id']}'";      
        
    $result mysql_query($query$link_id);
        if(
    mysql_error() != null){
            die(
    mysql_error());
        }
        if(
    $result)
        { 
            
    $flag "success";
        }
        else
        {
             
    $flag "error"
          }
        
    header("location:Student_Edit.php?flag=$flag&student_id=student_id=$student_id");
    ?>

  2. #2
    Join Date
    Jul 2013
    Location
    Voorheesville NY USA
    Posts
    898
    1 - proper syntax is usually:
    PHP Code:
    header("Location: scriptname.php"); 
    Note cap L and space after colon.

    2 - Your second call to header seems bogus. student_id=student_id=$student_id ?

    3 - You need to follow a header call with an Exit (or die if you insist on using that).

    4 - STOP using the MySQL_* functions. The MySQL extension..... OH - Never Mind. Go Read the Manual on any MySQL_* function.

  3. #3
    Join Date
    Mar 2007
    Location
    localhost
    Posts
    2,519
    Looks like you need a space between the : and S

    header("location: Student_Edit.php?flag={$flag}&student_id=student_id={$student_id}");

    If you are still getting an error then your $flag and $student_id must contain something that causes the error.
    Yes, I know I'm about as subtle as being hit by a bus..(\\.\ Aug08)
    Yep... I say it like I see it, even if it is like a baseball bat in the nutz... (\\.\ Aug08)
    I want to leave this world the same way I came into it, Screaming, Incontinent & No memory!
    I laughed that hard I burst my colostomy bag... (\\.\ May03)
    Life for some is like a car accident... Mine is like a motorway pile up...

    Problems with Vista? :: Getting Cryptic wid it. :: The 'C' word! :: Whois?

  4. #4
    Join Date
    Jul 2013
    Location
    Voorheesville NY USA
    Posts
    898
    Quote Originally Posted by \\.\ View Post
    Looks like you need a space between the : and S

    header("location: Student_Edit.php?flag={$flag}&student_id=student_id={$student_id}");
    Posted this 5 hours ago - no response yet!

  5. #5
    Join Date
    May 2014
    Posts
    77
    At the end:

    PHP Code:
    header("location:Student_Edit.php?flag=$flag&student_id=student_id=$student_id"); 
    Ignoring other pre-mentioned issues... I'm going to assume $flag or $student_id has a new line in it... Just guessing due to the nature of to the error message.

    PHP Code:
    header("Location: Student_Edit.php?flag=$flag&student_id=student_id=$student_id");
    if (
    strpos($flag"\n") !== false) {
        echo 
    '$flag has a new line!';
    }
    if (
    strpos($student_id"\n") !== false) {
        echo 
    '$student_id has a new line!';

    or probably...

    PHP Code:
    header("Location: Student_Edit.php?flag=$flag&student_id=$student_id");
    if (
    strpos($flag"\n") !== false) {
        echo 
    '$flag has a new line!';
    }
    if (
    strpos($student_id"\n") !== false) {
        echo 
    '$student_id has a new line!';


  6. #6
    Join Date
    May 2014
    Posts
    26
    @ginerjm Sorry for the late reply i just thought no one answers me here...

    But thank you for that i've been focusing on other page thinking it would spend me more time solving this but your suggstion number 2 solve the problem.
    thank u much

  7. #7
    Join Date
    Jul 2013
    Location
    Voorheesville NY USA
    Posts
    898
    Hth!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles