Error in modifying HTTP header information
<p>I am having this errors (I have checked around the line 5, and cant find any white line, and the sql on line, I have checked the spellings and syntax they re alright )</p>

<p>Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/reachea2/public_html/orderpplac.php on line 53</p>

<p>Warning: Cannot modify header information - headers already sent by (output started at /home/reachea2/public_html/orderpplac.php:53) in /home/reachea2/public_html/include/functions.php on line 5</p>

<pre><code>&lt;?php
require_once("include/session.php");
require_once("include/dataconnect.php"); 
require_once("include/functions.php");
if (isset($_POST['submit1'])) {
    if(array_key_exists('item', $_POST)){
        // $items = $_POST['item'];
        //foreach($_POST['item'] as $item){
            //echo $item['Pquantity'] . ", ";
            //echo $item['Pidno'] . ", ";
        // }
        //Loop through $_POST items, updating the database for each item
        foreach ($_POST['item'] as $item) { 
            $Pquantity = intval($item['Pquantity']);
            $Pidno = ($item['Pidno']); 
            //echo $Pquantity . ", ";
            //echo $Pidno . ", ";
            $queryreg = mysql_query("
                UPDATE repplac
                SET Pquantity = {$Pquantity}
                WHERE Pidno = '{$Pidno}'
                AND Uname = '{$_SESSION['username']}'
            ") or die(mysql_error());  
        }
    }
}
else if (isset($_POST['submit2'])) {
    //Get Email Address
    $emails = mysql_query("SELECT reusers.email FROM reusers INNER JOIN repplac ON reusers.username = repplac.Uname AND reusers.username = '{$_SESSION['username']}'")or die(mysql_error());
    //$emails = mysql_query("SELECT reusers.email FROM reusers INNER JOIN repplac ON reusers.username = repplac.Uname AND reusers.username = '".$_SESSION['username']."'")or die(mysql_error());
    $results = (mysql_fetch_assoc($emails)) or die(mysql_error());
    $email= $results['email'];
    //echo "$email";
    //die();
    if(mysql_num_rows($emails) == 0){
        exit("No email addresses found for user '{$_SESSION['username']}'");
    }
    $email = mysql_result($emails, 0);

    //Get list to email user
    $body = "&lt;html&gt;&lt;body&gt;&lt;table border='1'&gt;
    &lt;tr&gt;
        &lt;th&gt;Shop Name&lt;/th&gt;
        &lt;th&gt;Product Name&lt;/th&gt;
        &lt;th&gt;Size&lt;/th&gt;
        &lt;th&gt;Color Name&lt;/th&gt;
        &lt;th&gt;Quantity&lt;/th&gt;
    &lt;/tr&gt;";
    $pplresult = mysql_query("SELECT * FROM repplac WHERE Uname = '{$_SESSION['username']}')");   
    while($row = mysql_fetch_assoc($pplresult)){ 
        $body .= "&lt;tr&gt;
                &lt;td&gt;" . $row['Sname'] ."&lt;/td&gt;
                &lt;td&gt;" . $row['Pname'] ."&lt;/td&gt;
                &lt;td&gt;" . $row['Psize'] ."&lt;/td&gt;
                &lt;td&gt;" . $row['Pcolour'] ."&lt;/td&gt;
                &lt;td&gt;" . $row['Pquantity'] ."&lt;/td&gt;
            &lt;/tr&gt;";
    }

    $body .="&lt;/table&gt;&lt;/body&gt;&lt;/html&gt;";
    //Send email
    $to = $email; 
    $subject = "YOUR ORDER LIST FROM REACHEASY"; 
    $headers = "From: donotreply@rapsody.co.uk\r\n";  
    $headers  .= 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    mail($to,$subject,$body,$headers);
    //Transfer records to wishlist 
    $transfer = mysql_query("INSERT INTO wishlist (SELECT  * FROM repplac WHERE Uname = '{$_SESSION['username']}')")or die(mysql_error());
    // Delete temporary records if the above query was successful:
    if($transfer !== false){
        $deletetable = mysql_query("DELETE FROM repplac WHERE Uname = '{$_SESSION['username']}'");
    }
}
redirect_to('youraccount.php'); 
?&gt; body
</code></pre>
