182x Posted June 14, 2007 Share Posted June 14, 2007 Hey guys, I installed Xampp yesterday and I am still getting the following error message with the PHP code which I did not have before I installed xampp so i was just wondering why i am getting this error now? I also have the session_start at the top of the code. Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\xampp\htdocs\test\processUpload.php:4) Thanks Quote Link to comment https://forums.phpfreaks.com/topic/55617-php-error-message-again/ Share on other sites More sharing options...
ToonMariner Posted June 14, 2007 Share Posted June 14, 2007 on line 4 of that script you either have an echo or print statement or you have broken out of php and begun ouputting html OR just plain old white space. Quote Link to comment https://forums.phpfreaks.com/topic/55617-php-error-message-again/#findComment-274828 Share on other sites More sharing options...
182x Posted June 14, 2007 Author Share Posted June 14, 2007 Hi, I can't seem to find the problem, can you see it in the code? Sorry about the tabs they messed up when i copied the code. <html> <head> <title>pu</title> <style type="text/css"> <!-- .style1{font-family: Arial, Helvetica, sans-serif} --> </style> </head> <body bgcolor="#CCCCCC"> <p align="center" style="style1"> <?php session_start(); include('db.php'); $link_id = db_(''); $fl = "uw/"; $fl = $fl.$HTTP_POST_FILES['gf']['na']; $mn= $HTTP_POST_VARS['mn']; $pa = $fl; $an = $HTTP_POST_VARS['an']; $at = $HTTP_POST_VARS['at']; if(move_uploaded_file($HTTP_POST_FILES['gf']['tn'], $fl)) { $gu = "SELECT ui FROM up WHERE pa = '$fl'"; $re = mysql_query($gu, $link_id); if(mysql_num_rows($re) > 0 ) { ?> <p align="center" class="style1"> <?php echo "already exists"; ?> </p> <p align="center" class="style1"><a href="uw.php" class="style6">Back </a></span></p> <p align="center" class="style1"><a href="lo.php" class="style6">Logout</a></span></p> <?php exit(); } $iu="INSERT INTO upload VALUES('','$mn','$pa', '$an', '$at')"; mysql_query($iu, $link_id); ?> <p align="center" class="style1"> <?php echo "The selected file ".$HTTP_POST_FILES['gf']['na']. "";?> </p> <?php } else { ?> <p align="center" class="style1"> <?php echo "the file does not exist.";?> </p> <p align="center" class="style1"><a href="uw.php" class="style1">Back </a></span></p> <p align="center" class="style1"><a href="lo.php" class="style1">Logout</a></span></p> <?php exit(); } ?> </p> <p align="center" class="style1">Please click the following:</p> <p align="center" class="style1"><a href="ah.php">Home</a></p> <p align="center" class="style1"><a href="lo.php">Logout</a></p> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/55617-php-error-message-again/#findComment-274875 Share on other sites More sharing options...
conker87 Posted June 14, 2007 Share Posted June 14, 2007 You need to start the session before anything else is sent. Once you close the <head> tag (or echo something) then the headers have been sent. <?php session_start(); include('db.php'); $link_id = db_(''); ?><html> <head> <title>pu</title> <style type="text/css"> <!-- .style1{font-family: Arial, Helvetica, sans-serif} --> </style> </head> <body bgcolor="#CCCCCC"> <p align="center" style="style1"> <?php $fl = "uw/"; $fl = $fl.$HTTP_POST_FILES['gf']['na']; $mn= $HTTP_POST_VARS['mn']; $pa = $fl; $an = $HTTP_POST_VARS['an']; $at = $HTTP_POST_VARS['at']; if(move_uploaded_file($HTTP_POST_FILES['gf']['tn'], $fl)) { $gu = "SELECT ui FROM up WHERE pa = '$fl'"; $re = mysql_query($gu, $link_id); if(mysql_num_rows($re) > 0 ) { ?> <p align="center" class="style1"> <?php echo "already exists"; ?> </p> <p align="center" class="style1"><a href="uw.php" class="style6">Back </a></span></p> <p align="center" class="style1"><a href="lo.php" class="style6">Logout</a></span></p> <?php exit(); } $iu="INSERT INTO upload VALUES('','$mn','$pa', '$an', '$at')"; mysql_query($iu, $link_id); ?> <p align="center" class="style1"> <?php echo "The selected file ".$HTTP_POST_FILES['gf']['na']. "";?> </p> <?php } else { ?> <p align="center" class="style1"> <?php echo "the file does not exist.";?> </p> <p align="center" class="style1"><a href="uploadWork.php" class="style1">Back </a></span></p> <p align="center" class="style1"><a href="logout.php" class="style1">Logout</a></span></p> <?php exit(); } ?> </p> <p align="center" class="style1">Please click the following link to go to back to the admin home page:</p> <p align="center" class="style1"><a href="adminHome.php">Home</a></p> <p align="center" class="style1"><a href="logout.php">Logout</a></p> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/55617-php-error-message-again/#findComment-274879 Share on other sites More sharing options...
182x Posted June 14, 2007 Author Share Posted June 14, 2007 Ahh I see. Thanks so much for your help! The previous version of PHP I was using was PHP4 and Xampp uses PHP5 does the session_start() rule not apply for PHP4? Quote Link to comment https://forums.phpfreaks.com/topic/55617-php-error-message-again/#findComment-274884 Share on other sites More sharing options...
wildteen88 Posted June 14, 2007 Share Posted June 14, 2007 Yes it applies to all versions of PHP. You probably didn't see that error last time because your PHP4 setup had display_errors set to off so you didn't see the error - however you would of gotten a blank page instead. Or your PHP4 setup had output buffering enabled in the php.ini Quote Link to comment https://forums.phpfreaks.com/topic/55617-php-error-message-again/#findComment-274918 Share on other sites More sharing options...
182x Posted June 14, 2007 Author Share Posted June 14, 2007 Yes it applies to all versions of PHP. You probably didn't see that error last time because your PHP4 setup had display_errors set to off so you didn't see the error - however you would of gotten a blank page instead. Or your PHP4 setup had output buffering enabled in the php.ini Thanks again Am I best having output buffering enabled in the php.ini file? and is it also good practice to put the following code at the top of all the pages to avoid problems? <?php session_start(); ?> Quote Link to comment https://forums.phpfreaks.com/topic/55617-php-error-message-again/#findComment-274954 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.