Jump to content

Session Errors


OAFC_Rob

Recommended Posts

Hey,

 

I'm having a bit of trouble with some coding it's coming up with the following error message;

 

 

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/innova11/public_html/allsorts/productInfo.php:1) in /home/innova11/public_html/allsorts/productInfo.php on line 2

 

I cannot see any previously defined sessions on this coding, can anybody help me please. I am hosting this section as a sub domain on a host that has anopther site, but the files are in a seperate folder so I don't think thats affect it. Any ideas??

 

 

               <?php
                session_start();
                //Function to display the contact_errors in line
                function fieldError($fieldName, $errorArray)
                    {
                          if (isset($errorArray[$fieldName]))
                            {
                                echo "<font color=RED>$errorArray[$fieldName]</font><br>";
                            }
                          
                    } 
    
            ?>
            <?php include "sections/headerArea.php"; ?>     
            <?php include "sections/leftArea.php"; ?>
       
            <div class="rightContent"><!--OPEN DIV FOR RIGHT CONTENT -->
                <?php
                    
                    $id = $_GET['id'];
                    $product = $_GET['product'];
                    $query = "SELECT * FROM tbl_products WHERE id = '$id'"; 
                    $result = mysql_query($query) or die ("Error in query: $query. ".mysql_error()); 
                    if (mysql_num_rows($result) > 0) 
                        {
                            $row = mysql_fetch_array($result); 
                            print "
                                    <h1>$product >> " . $row["product_name"] . "</h1>
                                    
                                    <table class='details'>    
                                        <tr>
                                            <td>
                                                <img src=\"". $row["product_img"] ."\" alt='" . $row["product_name"] . "' />
                                            </td>
                                            <td>
                                                ". $row["product_description"] ."
                                            </td>
                                        </tr>
                                    </table>
                                    <table>
                                  ";
                            
                        } 
                    else
                        {
                            echo "Sorry, but we cannot seem to find that products information.";
                        } 
                 ?> 
                 <form method="post" action="response.php" enctype="multipart/form-data"> 
                 <?php
                    //See if there are any erros in the Session Error Array
                    if (count($_SESSION['errors']))
                     echo "
                            Please amend your details below as required. 
                            Sections shown in <font color=\"red\">RED</font> are mandatory
                          ";
                    else
                     echo "
                            Enquiry Form
                          ";  
                 ?>
                 
                     <table>
                        <tr>
                            <td>
                                <label for="name">Name</label>
                            </td>
                            <td>
                                <? echo fieldError("name", $_SESSION['errors']); ?>
                                <input type="text" name="name" id="name" size="15" 
                                value="<? echo $_SESSION['form_vars']["name"]; ?>" />
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <label for="email">E–Mail</label>
                            </td>
                            <td>
                                <? echo fieldError("email", $_SESSION['errors']); ?>
                                <input type="text" name="email" id="email" size="15" 
                                value="<? echo $_SESSION['form_vars']["email"]; ?>" />
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <label for="tphone">Telephone</label>
                            </td>
                            <td>
                                <? echo fieldError("tphone", $_SESSION['errors']); ?>
                                <input type="text" name="tphone" id="tphone" size="15" 
                                value="<? echo $_SESSION['form_vars']["tphone"]; ?>" />
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <input type="hidden" name="subject" value="<? echo $row["product_name"]; ?>" />
                            </td>
                            <td>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <input name="reset" type="reset" value="Clear" />
                            </td>    
                            <td>
                                <input type="submit" name="submit" id="submit" value="Submit" />
                            </td>
                        </tr>
                    </table>
                 </form> 
            </div><!-- CLOSE DIV FOR RIGHT CONTENT -->
            
             <?php include "sections/footerArea.php"; ?>                           

Link to comment
Share on other sites

output started at /home/innova11/public_html/allsorts/productInfo.php:1 (line 1)

 

^^^ Based on where your <?php tag is at, you have a tab or some space characters before the <?php tag. You cannot output any characters to the browser before a session_start() statement.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.