Jump to content
xisto Community
Sign in to follow this  
dsjoes

Header Error

Recommended Posts

i get the below message when i try to use the script near the bottom which deletes from an sql database and the linked file but if i put the script on a page on it's own it works without a hitch. so it is something else on his page that is causing the problem i have tried removing everything but the main design but it is then indicating the error is because of the divs i have used and every time i remove the one it wants it changes to another.

Warning: Cannot modify header information - headers already sent by (output started at /hermes/bosweb/web230/b2302/ipg.myaccount/test_server/admin/index.php:10) in /hermes/bosweb/web230/b2302/ipg.myaccount/test_server/admin/index.php on line 95

line 95 is this bit
header('Location: index.php');
and line ten is the stylesheet for uploadify

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://forums.xisto.com/no_longer_exists/ xmlns="http://forums.xisto.com/no_longer_exists/ http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>Testimonials</title><link href="../style.css" rel="stylesheet" type="text/css" /><link href="uploadify/uploadify.css" type="text/css" rel="stylesheet" />      <script type="text/javascript" src="uploadify/jquery-1.4.2.min.js"></script>      <script type="text/javascript" src="uploadify/swfobject.js"></script>      <script type="text/javascript" src="uploadify/jquery.uploadify.v2.1.4.min.js"></script>      <script type="text/javascript">      $(document).ready(function() {        $('#file_upload').uploadify({          'uploader'  : 'uploadify/uploadify.swf',          'script'    : 'uploadify/uploadify.php',          'cancelImg' : 'uploadify/cancel.png',          'folder'    : '../testimonial_files',          'auto'      : true        });      });      </script>      </head><body><div class="container">  <div class="header"><br /><br /><br /> </div>  <div class="sidebar1">    <ul class="nav"><b>      <li><a href="../">Home</a></li>      <li><a href="/admin/">Testimonials upload</a></li>      <li><a href="audio/">Audio Testimonials upload</a></li>      <li><a href="dvds/">Dvd's upload</a></li>      <li><a href="newsletter/">Newsletter upload</a></li>      <li><a href="news/">News box update</a></li>     </b></ul></div>  <div class="content">  <center><h2>Admin</h2></center>  <br /><center><p><input id="file_upload" name="file_upload" type="file" /></p><p><table width="200" border="0"><form action="insert_test.php" method="post">  <tr>    <td align="right">Name:</td>    <td><input type="text" name="Name" /></td>  </tr>  <tr>    <td align="right">Description:</td>    <td><input type="text" name="Message" /></td>  </tr>    <tr>    <td align="right">Download:</td>    <td><input name="Download" type="text" /></td>    </tr>    <tr>        <td colspan="2" align="center"><input type="submit" value="Submit" /></td>  </tr></form></table></p><br /><br /><p><?php// Set Global Vars$HOST = "";$USERNAME = "";$PASSWORD = "";$DATABASE = "";$TABLE = "";// Establish a connectionmysql_connect($HOST, $USERNAME, $PASSWORD) or die(mysql_error());mysql_select_db($DATABASE) or die(mysql_error());//==================================================================// Check if anything is posted//==================================================================if (isset($_POST['delete'])) {    $sql = ("delete from $TABLE where ");    for ($i = 0; $i < count($_POST['checkbox']); $i++) {        if ($i != 0) {            $sql.= "OR ";        }        $sql .= " id='" . $_POST['checkbox'][$i] . "'";        //==================================================================        // Select file to unlink based on id posted        //==================================================================        $sql_file_unlink = "select Download from $TABLE where id = {$_POST['checkbox'][$i]}";        $result_file_unlink =  mysql_query($sql_file_unlink);        $row_file_link = mysql_fetch_assoc($result_file_unlink);        if($row_file_link) {             unlink('../testimonial_files/' . $row_file_link['Download']);        }        //==================================================================    }    $result = mysql_query($sql);    header('Location: index.php');    exit;} else {    // select sql here    $sql = "select * from `$TABLE` order by `id`;";    $result = mysql_query($sql);}?><table  align="center" width="400" border="0" cellspacing="1" cellpadding="0">     <tr>      <td colspan="6" align="center"><strong>Testimonials</strong> </td>    </tr>    <tr>        <td><form name="delete" method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>">                <table width="400" border="1" cellpadding="3" cellspacing="1">                    <tr>                        <td align="center"><strong>Select</strong></td>                        <td align="center"><strong>ID</strong></td>                        <td align="center"><strong>Name</strong></td>                        <td align="center"><strong>Description</strong></td>                        <td align="center"><strong>Download</strong></td>                        <td align="center"><strong>Last Modified</strong></td>                    </tr><?php $row = mysql_fetch_assoc($result); ?><?php do { ?>                        <tr>                            <td align="center">                                <input name="checkbox[]" type="checkbox" id="checkbox[]" value="<?php echo $row['id']; ?>">                            </td>                            <td align="center"><?php echo $row['id']; ?></td>                            <td align="center"><?php echo $row['Name']; ?></td>                            <td align="center"><?php echo $row['Message']; ?></td>                            <td align="center"><a href="../testimonial_files/<?php echo $row['Download']; ?>">Download</a></td>                            <td align="center"><?php echo date("j/n/y", strtotime($row["Modified"])) ?></td>                        </tr>                      <?php                      } while ($row = mysql_fetch_assoc($result)); ?>                        <tr>                            <td colspan="6" align="center"><input name="delete" type="submit" id="delete" value="Delete"></td>                        </tr>                    </table>                </form>            </td>        </tr>    </table></p></center></div>  <div class="sidebar2">    <h4>Text here</h4>    <p> </p>  </div>  <div class="footer">    <center><p>Š Copyright 2010</p></center>    </div>  </div></body></html> 

Share this post


Link to post
Share on other sites

i get the below message when i try to use the script near the bottom which deletes from an sql database and the linked file but if i put the script on a page on it's own it works without a hitch. so it is something else on his page that is causing the problem i have tried removing everything but the main design but it is then indicating the error is because of the divs i have used and every time i remove the one it wants it changes to another.


line 95 is this bit

header('Location: index.php');
and line ten is the stylesheet for uploadify

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://forums.xisto.com/no_longer_exists/ xmlns="http://forums.xisto.com/no_longer_exists/ http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>Testimonials</title><link href="../style.css" rel="stylesheet" type="text/css" /><link href="uploadify/uploadify.css" type="text/css" rel="stylesheet" />      <script type="text/javascript" src="uploadify/jquery-1.4.2.min.js"></script>      <script type="text/javascript" src="uploadify/swfobject.js"></script>      <script type="text/javascript" src="uploadify/jquery.uploadify.v2.1.4.min.js"></script>      <script type="text/javascript">      $(document).ready(function() {        $('#file_upload').uploadify({          'uploader'  : 'uploadify/uploadify.swf',          'script'    : 'uploadify/uploadify.php',          'cancelImg' : 'uploadify/cancel.png',          'folder'    : '../testimonial_files',          'auto'      : true        });      });      </script>      </head><body><div class="container">  <div class="header"><br /><br /><br /> </div>  <div class="sidebar1">    <ul class="nav"><b>      <li><a href="../">Home</a></li>      <li><a href="/admin/">Testimonials upload</a></li>      <li><a href="audio/">Audio Testimonials upload</a></li>      <li><a href="dvds/">Dvd's upload</a></li>      <li><a href="newsletter/">Newsletter upload</a></li>      <li><a href="news/">News box update</a></li>     </b></ul></div>  <div class="content">  <center><h2>Admin</h2></center>  <br /><center><p><input id="file_upload" name="file_upload" type="file" /></p><p><table width="200" border="0"><form action="insert_test.php" method="post">  <tr>    <td align="right">Name:</td>    <td><input type="text" name="Name" /></td>  </tr>  <tr>    <td align="right">Description:</td>    <td><input type="text" name="Message" /></td>  </tr>    <tr>    <td align="right">Download:</td>    <td><input name="Download" type="text" /></td>    </tr>    <tr>        <td colspan="2" align="center"><input type="submit" value="Submit" /></td>  </tr></form></table></p><br /><br /><p><?php// Set Global Vars$HOST = "";$USERNAME = "";$PASSWORD = "";$DATABASE = "";$TABLE = "";// Establish a connectionmysql_connect($HOST, $USERNAME, $PASSWORD) or die(mysql_error());mysql_select_db($DATABASE) or die(mysql_error());//==================================================================// Check if anything is posted//==================================================================if (isset($_POST['delete'])) {    $sql = ("delete from $TABLE where ");    for ($i = 0; $i < count($_POST['checkbox']); $i++) {        if ($i != 0) {            $sql.= "OR ";        }        $sql .= " id='" . $_POST['checkbox'][$i] . "'";        //==================================================================        // Select file to unlink based on id posted        //==================================================================        $sql_file_unlink = "select Download from $TABLE where id = {$_POST['checkbox'][$i]}";        $result_file_unlink =  mysql_query($sql_file_unlink);        $row_file_link = mysql_fetch_assoc($result_file_unlink);        if($row_file_link) {             unlink('../testimonial_files/' . $row_file_link['Download']);        }        //==================================================================    }    $result = mysql_query($sql);    header('Location: index.php');    exit;} else {    // select sql here    $sql = "select * from `$TABLE` order by `id`;";    $result = mysql_query($sql);}?><table  align="center" width="400" border="0" cellspacing="1" cellpadding="0">     <tr>      <td colspan="6" align="center"><strong>Testimonials</strong> </td>    </tr>    <tr>        <td><form name="delete" method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>">                <table width="400" border="1" cellpadding="3" cellspacing="1">                    <tr>                        <td align="center"><strong>Select</strong></td>                        <td align="center"><strong>ID</strong></td>                        <td align="center"><strong>Name</strong></td>                        <td align="center"><strong>Description</strong></td>                        <td align="center"><strong>Download</strong></td>                        <td align="center"><strong>Last Modified</strong></td>                    </tr><?php $row = mysql_fetch_assoc($result); ?><?php do { ?>                        <tr>                            <td align="center">                                <input name="checkbox[]" type="checkbox" id="checkbox[]" value="<?php echo $row['id']; ?>">                            </td>                            <td align="center"><?php echo $row['id']; ?></td>                            <td align="center"><?php echo $row['Name']; ?></td>                            <td align="center"><?php echo $row['Message']; ?></td>                            <td align="center"><a href="../testimonial_files/<?php echo $row['Download']; ?>">Download</a></td>                            <td align="center"><?php echo date("j/n/y", strtotime($row["Modified"])) ?></td>                        </tr>                      <?php                      } while ($row = mysql_fetch_assoc($result)); ?>                        <tr>                            <td colspan="6" align="center"><input name="delete" type="submit" id="delete" value="Delete"></td>                        </tr>                    </table>                </form>            </td>        </tr>    </table></p></center></div>  <div class="sidebar2">    <h4>Text here</h4>    <p> </p>  </div>  <div class="footer">    <center><p>Š Copyright 2010</p></center>    </div>  </div></body></html> 

The reason for that error is because you have already began outputting HTML code so redirecting after that point is not possible. You can move your whole PHP code block to the top before you begin your HTML output and it should work.

<?php// Set Global Vars$HOST = "";$USERNAME = "";$PASSWORD = "";$DATABASE = "";$TABLE = "";// Establish a connectionmysql_connect($HOST, $USERNAME, $PASSWORD) or die(mysql_error());mysql_select_db($DATABASE) or die(mysql_error());//==================================================================// Check if anything is posted//==================================================================if (isset($_POST['delete'])) {    $sql = ("delete from $TABLE where ");    for ($i = 0; $i < count($_POST['checkbox']); $i++) {        if ($i != 0) {            $sql.= "OR ";        }        $sql .= " id='" . $_POST['checkbox'][$i] . "'";        //==================================================================        // Select file to unlink based on id posted        //==================================================================        $sql_file_unlink = "select Download from $TABLE where id = {$_POST['checkbox'][$i]}";        $result_file_unlink =  mysql_query($sql_file_unlink);        $row_file_link = mysql_fetch_assoc($result_file_unlink);        if($row_file_link) {             unlink('../testimonial_files/' . $row_file_link['Download']);        }        //==================================================================    }    $result = mysql_query($sql);    header('Location: index.php');    exit;} else {    // select sql here    $sql = "select * from `$TABLE` order by `id`;";    $result = mysql_query($sql);}?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://forums.xisto.com/no_longer_exists/ xmlns="http://forums.xisto.com/no_longer_exists/ http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>Testimonials</title><link href="../style.css" rel="stylesheet" type="text/css" /><link href="uploadify/uploadify.css" type="text/css" rel="stylesheet" />      <script type="text/javascript" src="uploadify/jquery-1.4.2.min.js"></script>      <script type="text/javascript" src="uploadify/swfobject.js"></script>      <script type="text/javascript" src="uploadify/jquery.uploadify.v2.1.4.min.js"></script>      <script type="text/javascript">      $(document).ready(function() {        $('#file_upload').uploadify({          'uploader'  : 'uploadify/uploadify.swf',          'script'    : 'uploadify/uploadify.php',          'cancelImg' : 'uploadify/cancel.png',          'folder'    : '../testimonial_files',          'auto'      : true        });      });      </script>      </head><body><div class="container">  <div class="header"><br /><br /><br /> </div>  <div class="sidebar1">    <ul class="nav"><b>      <li><a href="../">Home</a></li>      <li><a href="/admin/">Testimonials upload</a></li>      <li><a href="audio/">Audio Testimonials upload</a></li>      <li><a href="dvds/">Dvd's upload</a></li>      <li><a href="newsletter/">Newsletter upload</a></li>      <li><a href="news/">News box update</a></li>     </b></ul></div>  <div class="content">  <center><h2>Admin</h2></center>  <br /><center><p><input id="file_upload" name="file_upload" type="file" /></p><p><table width="200" border="0"><form action="insert_test.php" method="post">  <tr>    <td align="right">Name:</td>    <td><input type="text" name="Name" /></td>  </tr>  <tr>    <td align="right">Description:</td>    <td><input type="text" name="Message" /></td>  </tr>    <tr>    <td align="right">Download:</td>    <td><input name="Download" type="text" /></td>    </tr>    <tr>        <td colspan="2" align="center"><input type="submit" value="Submit" /></td>  </tr></form></table></p><br /><br /><p><table  align="center" width="400" border="0" cellspacing="1" cellpadding="0">     <tr>      <td colspan="6" align="center"><strong>Testimonials</strong> </td>    </tr>    <tr>        <td><form name="delete" method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>">                <table width="400" border="1" cellpadding="3" cellspacing="1">                    <tr>                        <td align="center"><strong>Select</strong></td>                        <td align="center"><strong>ID</strong></td>                        <td align="center"><strong>Name</strong></td>                        <td align="center"><strong>Description</strong></td>                        <td align="center"><strong>Download</strong></td>                        <td align="center"><strong>Last Modified</strong></td>                    </tr><?php $row = mysql_fetch_assoc($result); ?><?php do { ?>                        <tr>                            <td align="center">                                <input name="checkbox[]" type="checkbox" id="checkbox[]" value="<?php echo $row['id']; ?>">                            </td>                            <td align="center"><?php echo $row['id']; ?></td>                            <td align="center"><?php echo $row['Name']; ?></td>                            <td align="center"><?php echo $row['Message']; ?></td>                            <td align="center"><a href="../testimonial_files/<?php echo $row['Download']; ?>">Download</a></td>                            <td align="center"><?php echo date("j/n/y", strtotime($row["Modified"])) ?></td>                        </tr>                      <?php                      } while ($row = mysql_fetch_assoc($result)); ?>                        <tr>                            <td colspan="6" align="center"><input name="delete" type="submit" id="delete" value="Delete"></td>                        </tr>                    </table>                </form>            </td>        </tr>    </table></p></center></div>  <div class="sidebar2">    <h4>Text here</h4>    <p> </p>  </div>  <div class="footer">    <center><p>Š Copyright 2010</p></center>    </div>  </div></body></html>

Share this post


Link to post
Share on other sites

Hi!What you need to do is create an intermediary script that either outputs the header to redirect to index.php or include another file that contains the markup with the stylesheet or anything else that you choose to include. This approach will not only fix the problem that you are experiencing but will also make your code better organized (and I'm sure folks would want to debate on that bit... what constitutes a good design is something fairly subjective).If you do need more help with the problem, feel free to reply or send me a private message/email/instant message and I'll try to get back to you as soon as I can.

Share this post


Link to post
Share on other sites

The reason for that error is because you have already began outputting HTML code so redirecting after that point is not possible. You can move your whole PHP code block to the top before you begin your HTML output and it should work.

<?php// Set Global Vars$HOST = "";$USERNAME = "";$PASSWORD = "";$DATABASE = "";$TABLE = "";// Establish a connectionmysql_connect($HOST, $USERNAME, $PASSWORD) or die(mysql_error());mysql_select_db($DATABASE) or die(mysql_error());//==================================================================// Check if anything is posted//==================================================================if (isset($_POST['delete'])) {    $sql = ("delete from $TABLE where ");    for ($i = 0; $i < count($_POST['checkbox']); $i++) {        if ($i != 0) {            $sql.= "OR ";        }        $sql .= " id='" . $_POST['checkbox'][$i] . "'";        //==================================================================        // Select file to unlink based on id posted        //==================================================================        $sql_file_unlink = "select Download from $TABLE where id = {$_POST['checkbox'][$i]}";        $result_file_unlink =  mysql_query($sql_file_unlink);        $row_file_link = mysql_fetch_assoc($result_file_unlink);        if($row_file_link) {             unlink('../testimonial_files/' . $row_file_link['Download']);        }        //==================================================================    }    $result = mysql_query($sql);    header('Location: index.php');    exit;} else {    // select sql here    $sql = "select * from `$TABLE` order by `id`;";    $result = mysql_query($sql);}?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://forums.xisto.com/no_longer_exists/ xmlns="http://forums.xisto.com/no_longer_exists/ http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>Testimonials</title><link href="../style.css" rel="stylesheet" type="text/css" /><link href="uploadify/uploadify.css" type="text/css" rel="stylesheet" />      <script type="text/javascript" src="uploadify/jquery-1.4.2.min.js"></script>      <script type="text/javascript" src="uploadify/swfobject.js"></script>      <script type="text/javascript" src="uploadify/jquery.uploadify.v2.1.4.min.js"></script>      <script type="text/javascript">      $(document).ready(function() {        $('#file_upload').uploadify({          'uploader'  : 'uploadify/uploadify.swf',          'script'    : 'uploadify/uploadify.php',          'cancelImg' : 'uploadify/cancel.png',          'folder'    : '../testimonial_files',          'auto'      : true        });      });      </script>      </head><body><div class="container">  <div class="header"><br /><br /><br /> </div>  <div class="sidebar1">    <ul class="nav"><b>      <li><a href="../">Home</a></li>      <li><a href="/admin/">Testimonials upload</a></li>      <li><a href="audio/">Audio Testimonials upload</a></li>      <li><a href="dvds/">Dvd's upload</a></li>      <li><a href="newsletter/">Newsletter upload</a></li>      <li><a href="news/">News box update</a></li>     </b></ul></div>  <div class="content">  <center><h2>Admin</h2></center>  <br /><center><p><input id="file_upload" name="file_upload" type="file" /></p><p><table width="200" border="0"><form action="insert_test.php" method="post">  <tr>    <td align="right">Name:</td>    <td><input type="text" name="Name" /></td>  </tr>  <tr>    <td align="right">Description:</td>    <td><input type="text" name="Message" /></td>  </tr>    <tr>    <td align="right">Download:</td>    <td><input name="Download" type="text" /></td>    </tr>    <tr>        <td colspan="2" align="center"><input type="submit" value="Submit" /></td>  </tr></form></table></p><br /><br /><p><table  align="center" width="400" border="0" cellspacing="1" cellpadding="0">     <tr>      <td colspan="6" align="center"><strong>Testimonials</strong> </td>    </tr>    <tr>        <td><form name="delete" method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>">                <table width="400" border="1" cellpadding="3" cellspacing="1">                    <tr>                        <td align="center"><strong>Select</strong></td>                        <td align="center"><strong>ID</strong></td>                        <td align="center"><strong>Name</strong></td>                        <td align="center"><strong>Description</strong></td>                        <td align="center"><strong>Download</strong></td>                        <td align="center"><strong>Last Modified</strong></td>                    </tr><?php $row = mysql_fetch_assoc($result); ?><?php do { ?>                        <tr>                            <td align="center">                                <input name="checkbox[]" type="checkbox" id="checkbox[]" value="<?php echo $row['id']; ?>">                            </td>                            <td align="center"><?php echo $row['id']; ?></td>                            <td align="center"><?php echo $row['Name']; ?></td>                            <td align="center"><?php echo $row['Message']; ?></td>                            <td align="center"><a href="../testimonial_files/<?php echo $row['Download']; ?>">Download</a></td>                            <td align="center"><?php echo date("j/n/y", strtotime($row["Modified"])) ?></td>                        </tr>                      <?php                      } while ($row = mysql_fetch_assoc($result)); ?>                        <tr>                            <td colspan="6" align="center"><input name="delete" type="submit" id="delete" value="Delete"></td>                        </tr>                    </table>                </form>            </td>        </tr>    </table></p></center></div>  <div class="sidebar2">    <h4>Text here</h4>    <p> </p>  </div>  <div class="footer">    <center><p>Š Copyright 2010</p></center>    </div>  </div></body></html>
thanks that worked

Share this post


Link to post
Share on other sites

Another solution is to start using output buffering, which will send the produced output only the php script stops executing or when you tell it to do it.All you need is to use ob_start() function: http://de1.php.net/manual-lookup.php?pattern=ob_startWith〈=en&scope=404quickref the combination of ob_* functions, you can make a lot of things quite easily, it lets you control your content and you can start using GZip as a handler for output buffering, but to use it right, I would suggest to read a little bit on this subject - PHP output buffering.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | 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.