tim101011 Posted October 28, 2007 Share Posted October 28, 2007 I have a page on my website that deletes pictures a user has uploaded. I am getting this error: Warning: Cannot modify header information - headers already sent by (output started at /var/www/vhosts/propertyeagle.co.uk/httpdocs/processdeletepostings.php:20) in /var/www/vhosts/propertyeagle.co.uk/httpdocs/processdeletepostings.php on line 79 And the user is not being redirected to the next page after the deletion as coded Here is the code: <?php session_start(); //check the user logged in legitamatley if not redirect them to the login page if ($_SESSION['$specialcode']!=session_id()){ header("location:logonpage.htm");} //connect to the db require_once ('./connecttodb.php'); //delete selected postings from db and check if anything was selected $a=0; if ($_POST['C1']!="") { $id = $_POST['C1']; $query= "DELETE from property where id= '$id'"; $result = @mysql_query ($query); $a=1; echo $id; deletepictures($id); } if ($_POST['C2']!="") { $id = $_POST['C2']; $query= "DELETE from property where id= '$id'"; $result = @mysql_query ($query); $a=1; deletepictures($id); } if ($_POST['C3']!="") { $id = $_POST['C3']; $query= "DELETE from property where id= '$id'"; $result = @mysql_query ($query); $a=1; deletepictures($id); } function deletepictures($id) { if (file_exists ("uploads/".$id."a.jpg")) {unlink ("uploads/".$id."a.jpg");} if (file_exists ("uploads/".$id."b.jpg")) {unlink ("uploads/".$id."b.jpg");} if (file_exists ("uploads/".$id."c.jpg")) {unlink ("uploads/".$id."c.jpg");} if (file_exists ("uploads/".$id."d.jpg")) {unlink ("uploads/".$id."d.jpg");} if (file_exists ("uploads/".$id."e.jpg")) {unlink ("uploads/".$id."e.jpg");} if (file_exists ("uploads/".$id."a.gif")) {unlink ("uploads/".$id."a.gif");} if (file_exists ("uploads/".$id."b.gif")) {unlink ("uploads/".$id."b.gif");} if (file_exists ("uploads/".$id."c.gif")) {unlink ("uploads/".$id."c.gif");} if (file_exists ("uploads/".$id."d.gif")) {unlink ("uploads/".$id."d.gif");} if (file_exists ("uploads/".$id."e.gif")) {unlink ("uploads/".$id."e.gif");} if (file_exists ("uploads/".$id."a.bmp")) {unlink ("uploads/".$id."a.bmp");} if (file_exists ("uploads/".$id."b.bmp")) {unlink ("uploads/".$id."b.bmp");} if (file_exists ("uploads/".$id."c.bmp")) {unlink ("uploads/".$id."c.bmp");} if (file_exists ("uploads/".$id."d.bmp")) {unlink ("uploads/".$id."d.bmp");} if (file_exists ("uploads/".$id."e.bmp")) {unlink ("uploads/".$id."e.bmp");} } //check how many active postings the user has and store the value in the session // variable used for navigation link activation/ deactivation $userid = $_SESSION['user_id']; $sql="SELECT * FROM property WHERE userid='$userid'"; $result=mysql_query($sql); $count=mysql_num_rows($result); $_SESSION['postings'] = $count; //redirect to search page if ($a==1){header("location:searchproperties.php?id=deletesuccesfull");} else {header("location:deletepostings.php");} ?> Any ideas? I have already positioned the "session_start();" statement at the very top. Thankyou kindly Quote Link to comment https://forums.phpfreaks.com/topic/75103-warning-cannot-modify-header-information-headers-already-sent/ Share on other sites More sharing options...
trq Posted October 28, 2007 Share Posted October 28, 2007 Did you read the sticky at the top of this forum? Quote Link to comment https://forums.phpfreaks.com/topic/75103-warning-cannot-modify-header-information-headers-already-sent/#findComment-379833 Share on other sites More sharing options...
tim101011 Posted October 28, 2007 Author Share Posted October 28, 2007 Yes, from top to bottom :-\ I am still non the wiser. Quote Link to comment https://forums.phpfreaks.com/topic/75103-warning-cannot-modify-header-information-headers-already-sent/#findComment-379846 Share on other sites More sharing options...
trq Posted October 28, 2007 Share Posted October 28, 2007 Do you have any whitespace before your <?php tag? You do in your post. Quote Link to comment https://forums.phpfreaks.com/topic/75103-warning-cannot-modify-header-information-headers-already-sent/#findComment-379848 Share on other sites More sharing options...
tim101011 Posted October 28, 2007 Author Share Posted October 28, 2007 No, definitely not. Sorry, that's just the way i pasted the code into the post here Quote Link to comment https://forums.phpfreaks.com/topic/75103-warning-cannot-modify-header-information-headers-already-sent/#findComment-379855 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.