Jump to content

Session start error


regoch
 Share

Recommended Posts

I got this error on my galerije-unos-slike.php and can't find where I start session for seccond time. Any clues? I turn error reporting off, script works fine but client is asking why error message apear.  On every other php page in admin I got same php code but don't get error message.

<?php 
//Start session
session_start();

if(!isset($_SESSION['SESS_MEMBER_ID']) || (trim($_SESSION['SESS_MEMBER_ID']) == '')) {
	header("location: prijava.php");
	exit();
}

require_once('config.php');
include ("include/head.php"); ?> 

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/udrugadj/public_html/admin/galerije-unos-slike.php:1) in /home/udrugadj/public_html/admin/galerije-unos-slike.php on line 1

 

<?php 
//Start session
session_start();

if(!isset($_SESSION['SESS_MEMBER_ID']) || (trim($_SESSION['SESS_MEMBER_ID']) == '')) {
	header("location: prijava.php");
	exit();
}

require_once('config.php');
include ("include/head.php"); ?>
<body>

<div id="main_container">

<div class="header">
    <div class="logo"><a href="index.php"><img src="images/logo.gif" alt="" title="" border="0" /></a></div>
    
    <div class="right_header">Administrator: <?php echo $_SESSION['SESS_FIRST_NAME'];?> | <a href="odjava.php" class="logout">Odjavi se</a></div>
    <div class="jclock"></div>
    </div>
    
    <div class="main_content">
    
                    <?php include ("include/menu.php");?>                
                    
    <div class="center_content">  
    
           
    <div class="right_content">            
        
       
     <h2>Admin Panel - Unos slika</h2>
     
         <div class="form">
<?php 
error_reporting(0);

$change="";
$abc="";


define ("MAX_SIZE","4096");
function getExtension($str) {
         $i = strrpos($str,".");
         if (!$i) { return ""; }
         $l = strlen($str) - $i;
         $ext = substr($str,$i+1,$l);
         return $ext;
}

$errors=0;




$slike = array(file, file1, file2, file3, file4);
  if($_SERVER["REQUEST_METHOD"] == "POST")
{
//	$image =$_FILES["file"]["name"];
//	$uploadedfile = $_FILES['file']['tmp_name'];
$filearray = array();
$filearray1 = array();
$k=0;

  foreach($slike as $slika){ 
$image =$_FILES[$slika]["name"];
$uploadedfile = $_FILES[$slika]['tmp_name'];
	if ($image) 
	{

		$filename = stripslashes($_FILES[$slika]['name']);

  		$extension = getExtension($filename);
		$extension = strtolower($extension);


if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") && ($extension != "gif")) 
		{

			$change='<div class="msgdiv">Unknown Image extension </div> ';
			$errors=1;
		}
		else
		{

$size=filesize($_FILES[$slika]['tmp_name']);


if ($size > MAX_SIZE*4096)
{
$change='<div class="msgdiv">Slika je veća od 4096kb!</div> ';
$errors=1;
}


if($extension=="jpg" || $extension=="jpeg" )
{
$uploadedfile = $_FILES[$slika]['tmp_name'];
$src = imagecreatefromjpeg($uploadedfile);

}
else if($extension=="png")
{
$uploadedfile = $_FILES[$slika]['tmp_name'];
$src = imagecreatefrompng($uploadedfile);

}
else 
{
$src = imagecreatefromgif($uploadedfile);
}

echo $scr;

list($width,$height)=getimagesize($uploadedfile);


$newheight=370;
$newwidth=($width/$height)*$newheight;
$tmp=imagecreatetruecolor($newwidth,$newheight);

$newheight1=170;
$newwidth1=($width/$height)*$newheight1;
$tmp1=imagecreatetruecolor($newwidth1,$newheight1);

imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height);

imagecopyresampled($tmp1,$src,0,0,0,0,$newwidth1,$newheight1,$width,$height);


//$filename = "images/". $_FILES['file']['name'];

//$filename1 = "images/small". $_FILES['file']['name'];
$rand = rand(0000000000, 9999999999);
$image_name=(date("dmY")+$k).'_'.$rand.'.'.$extension;
$filename = "../slike/".$image_name;
$filename1 = "../slike/thumbnails/".$image_name;
$filename3 = $image_name;
$filename4 = $image_name;
$id_galerije = $_GET['id_galerije'];

imagejpeg($tmp,$filename,100);

imagejpeg($tmp1,$filename1,100);



$filearray[$k]= $filename3;
$filearray1[$k]= $filename4;
$filearray2[$k]= $id_galerije;
$k++;

// 3. Perform database query
mysql_query("INSERT INTO slike set picture_name='$filename3', picture_name1='$filename4', id_galerije='$id_galerije'");
echo '<br /><img src="../slike/thumbnails/'.$filename4.'"><br />';
imagedestroy($src);
imagedestroy($tmp);
imagedestroy($tmp1);
}}
}
}
// If no errors registred, print the success message
if(isset($_POST['Submit']) && !$errors) 
{
	if ($filename3==""){
echo " <table width='400px' align='center' cellspacing='0'>
<tr bgcolor='#E6e6e6' height='26'>
	<td align='center' width='100%' colspan='2'><strong>Potvrda</strong></td>
</tr>
<tr bgcolor='#F6f6f6'>
    <td align='center' style='border-left:#E6e6e6 1px solid;border-bottom:#E6e6e6 1px solid;'><img src='images/warning.png'></td>
<td align='center' width='80'% style='border-right:#E6e6e6 1px solid;border-bottom:#E6e6e6 1px solid;'><strong>Slike nisu unešene.</strong></td>
</tr>
</table><br />";
}
else{ 
	echo " <table width='400px' align='center' cellspacing='0'>
<tr bgcolor='#E6e6e6' height='26'>
	<td align='center' width='100%' colspan='2'><strong>Potvrda</strong></td>
</tr>
<tr bgcolor='#F6f6f6'>
    <td align='center' style='border-left:#E6e6e6 1px solid;border-bottom:#E6e6e6 1px solid;'><img src='images/valid.png'></td>
<td align='center' width='80'% style='border-right:#E6e6e6 1px solid;border-bottom:#E6e6e6 1px solid;'><strong>Slike uspješno unesene.</strong></td>
</tr>
</table><br />";
}
}
/*If no errors registred, print the success message
if(isset($_POST['Submit']) && !$errors) 
{

   // mysql_query("update {$prefix}users set img='$big',img_small='$small' where user_id='$user'");
	$change=' <div class="msgdiv">Image Uploaded Successfully!</div>';
}*/


?>
     <div align="center" id="err">
<?php echo $change; ?>  </div>
		    
<form method="post" action="" enctype="multipart/form-data" name="form1">
<?php foreach($slike as $c){ ?>
    <input size="25" name="<?php echo $c?>" type="file" style="font-family:Verdana, Arial, Helvetica, sans-serif; font-size:10pt" class="box"/><br />
    <?php } ?>
Dozvoljen je unos slika veličine do 4 mb! <br />
<input type="submit" id="mybut" value="Unesi slike" name="Submit"/>
</form>
  
<?php 
// 5. Close connection
mysql_close($connection);
?>
         </div>  
      
     
     </div><!-- end of right content-->
            
                    
  </div>   <!--end of center content -->               
                    
                    
    
    
    <div class="clear"></div>
    </div> <!--end of main content-->

    
    <div class="footer"><br />
    
<?php include ("include/footer.php"); ?>
    
    </div>

</div>		
</body>
</html>

Link to comment
Share on other sites

head.php, menu.php, footer.php are just html in php file, no php code inside, and this is in config.php

	//Podaci za spajanje na bazu podataka
define('DB_HOST', 'localhost');
    define('DB_USER', '...);
    define('DB_PASSWORD', '....');
    define('DB_DATABASE', '...');

//Array za provjeru jesu li ispunjena sva polja
$errmsg_arr = array();

//Isključivanje provjere jesu li ispunjena sva polja
$errflag = false;

//Spajanje na mysql server
$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
if(!$link) {
	die('Greška prilikom spajanja na server: ' . mysql_error());
}

//Odabir baze podataka
$db = mysql_select_db(DB_DATABASE);
if(!$db) {
	die("Greška prilikom spajanja na bazu podataka");
}

Link to comment
Share on other sites

It's in this code:

 

<?php 
//Start session
session_start();

if(!isset($_SESSION['SESS_MEMBER_ID']) || (trim($_SESSION['SESS_MEMBER_ID']) == '')) {
	header("location: prijava.php");
	exit();
}

require_once('config.php');
include ("include/head.php"); ?>
<body>

<div id="main_container">

 

I'm assuming you have HTML tags before this php script.  header needs to be called before any output. 

 

<?php 
// ETC...
// header goes up here before <html> tag
?>

<html><head> etc...

Link to comment
Share on other sites

You are not trying to start the session two times, you are sending output on line 1 of your file - output started at /home/udrugadj/public_html/admin/galerije-unos-slike.php:1

 

You either have some character(s) in your file before the <?php tag or your file is saved with the BOM characters - please read the following sticky topic (particularly the last reply in it) - http://www.phpfreaks.com/forums/index.php?topic=37442.0

Link to comment
Share on other sites

It's in this code:

 

<?php 
//Start session
session_start();

if(!isset($_SESSION['SESS_MEMBER_ID']) || (trim($_SESSION['SESS_MEMBER_ID']) == '')) {
	header("location: prijava.php");
	exit();
}

require_once('config.php');
include ("include/head.php"); ?>
<body>

<div id="main_container">

 

I'm assuming you have HTML tags before this php script.  header needs to be called before any output. 

 

<?php 
// ETC...
// header goes up here before <html> tag
?>

<html><head> etc...

I first call php then call hedaers from head php
Link to comment
Share on other sites

When sending headers in you PHP, there cannot be not one character before it, and that includes, not even space.

I copy/paste first lines from other pages that don't show error and nothing, error is still here! I don't get it why in other pages dont' get any error.

Link to comment
Share on other sites

I copy paste upload script in other php page and sav it as galerije-unos-slike.php and there is no error now, but still not get why was there. Thanks for help!

 

You are not trying to start the session two times, you are sending output on line 1 of your file - output started at /home/udrugadj/public_html/admin/galerije-unos-slike.php:1

 

You either have some character(s) in your file before the <?php tag or your file is saved with the BOM characters - please read the following sticky topic (particularly the last reply in it) - http://www.phpfreaks.com/forums/index.php?topic=37442.0

Link to comment
Share on other sites

This thread is more than a year old.

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.

 Share

×
×
  • 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.