Jump to content

Recommended Posts

Iv written a script that allows users to delete multiple files from a database using check boxes.

However, im gettin this error......

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\p3t\public_php\cw\LINUX\multipledelete.php:1) in C:\p3t\public_php\cw\LINUX\multipledelete.php on line 2

here is my process page....

[code]
<?php
session_start();

require("cw1/connect.php");
require("cw1/dbselect.php");

if (!isset($_SESSION['sessEmployee']))
{
include("index.php");
return; //a return here terminates the execution of this page.
}

//create vars to store the two fields we will be using
$artefactId = "artefactId";
$filename = "filename";

//query to get list of items in the table
$query = "SELECT artefactId, filename FROM artefact WHERE dbEmployeeId='".$_SESSION['sessEmployee']['id']."' ORDER BY artefactId ASC";
$result = mysql_query($query);


//if the form was submitted, delete the items selected from the database
if (isset($_POST["deleted_items"]))
{
$deleted_items = join(', ', $_POST["deleted_items"]);
$query = "DELETE FROM artefact WHERE artefactId IN ($deleted_items)";
$result = mysql_query($query);
echo 'Files Deleted';
echo '<p><a href="viewuploads.php"> View Uploads </a></p>';
echo '<p><a href="login.php"> Home </a></p>';
return;
}

require("multipledelete.view.php");

?>
[/code]

And here is my view page ....

[code]

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>TECH3001 – Publishing and Production III – Coursework 1 </title>
</head>
<body>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<table width="50%" border="1" cellpadding="1" cellspacing="0">
<tr>
<td align="center" width="5%"><b>Id</b></td>
<td width="40%"><b>Filename</b></td>
<td align="center" width="5%"><b>Delete</b></td>
</tr>
<?php
//display the form so the user can delete one or more items from the table
while ($row = mysql_fetch_assoc($result))
{
echo '<td align="center">'.$row[$artefactId].'</td>';
echo '<td>'.$row[$filename].'</td>';
echo '<td align="center"><input type="checkbox" name="deleted_items[]" ';
echo 'value="'.$row[$artefactId].'" /></td>';
echo "</tr>";
}
echo '<p><a href="login.php"> Home </a></p>';
?>
</table>
<p><input type="submit" value="Delete Selected Items" /></p>
</form>
</body>
</html>
[/code]

CAN ANYONE HELP ME PLEASE!!!??

lol its driving me mad, I dont get the error if i put the whole thing into 1 php file
Link to comment
https://forums.phpfreaks.com/topic/33305-solved-problems-with-session-start/
Share on other sites

[code]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>TECH3001 – Publishing and Production III – Coursework 1 </title>
</head>

<body>
<p>
<?php
if (isset($useCaseOutcomeMessage))
{
echo( $useCaseOutcomeMessage . "<br /> \n");
}
if (isset($_SESSION['sessEmployee']))
{

echo("<ul><li><a href='upload.php'  >Upload Files</a><br /> \n</li></ul>");
echo("<ul><li><a href='viewuploads.php'  >View Uploads</a><br /> \n</li></ul>");
echo("<ul><li><a href='multipledelete.php'  >Delete Multiple Files</a><br /> \n</li></ul>");
echo("<ul><li><a href='logout.php' >Logout</a><br /> \n");
echo("<p>" . $_SESSION['sessEmployee']['UserName'] . " is logged in. <br /><br /></p> \n</li></ul>");
}
else
{
echo("<ul><li><a href='login.php' >Login</a><br /> \n</li></ul>");
}
?>
</p>

</body>
</html>

[/code]

Did you read this thread?
http://www.phpfreaks.com/forums/index.php/topic,37442.0.html

In the code you pasted, you have a space right here:
<?php
session_start();

That space is being sent to the browser, if that is in your code.
well i was curious if there was something causing it in those 2 required pages...perhaps instead of calling session_start();  make a separate page called startSession.php and use require_once('startSession.php');

require_once will check and see if that page has already been loaded aka your session is started by something else and then boom it wont load the session again..meh..that's how i do things on my site
The error message indicates that output was started on line 1 [b]<?php[/b] I am guessing that you are FTP'ing these files to where they are being executed? A number of times, non-displayable language setting characters exist at the beginning of text files.

Make sure that you are FTP'ing in ASCII mode and not BINARY mode.

Also, make a new empty file using your program editor and copy/past the contents of the problem file into the new file.
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.