Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,207,519 members, 7,999,315 topics. Date: Monday, 11 November 2024 at 01:07 AM |
Nairaland Forum / Science/Technology / Webmasters / I'm Getting "Warning: Session_start() [function.session-start]" Error. Pls Help (3138 Views)
500 Internal Server Error >>>>>> Pls Explain / I Keep Getting This Error::pls Help ::parse Error: Syntax Error, Unexpected '.', / Php Error. .Pls Help! (2) (3) (4)
I'm Getting "Warning: Session_start() [function.session-start]" Error. Pls Help by Nobody: 11:51pm On Jul 20, 2014 |
Experienced webmasters in the house, please I need your help and advice. I uploaded an application in php and when I load it, I usually get this error: "Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/afriport/public_html/apn101/admin/adminhome.php:1) in /home/afriport/public_html/apn101/admin/session.php on line 1" Please note that this is not the first time I am running this application. I have sucessfully uploaded it in a different domain previously without issues. But after editing the mysql information and uploading it to another server/domain, this is the error message I am getting. What could have gone wrong? This is the screenshot of the php script attached below
|
Re: I'm Getting "Warning: Session_start() [function.session-start]" Error. Pls Help by dignityonly: 12:16am On Jul 21, 2014 |
use ob_start(); on your first line. <?PHP ob_start(); session_start(); if(){ }else{ } ?> NOTE: This not the best way to go about it, but it will suppress your error. You can find other solutions here http://stackoverflow.com/questions/8028957/how-to-fix-headers-already-sent-error-in-php 1 Like |
Re: I'm Getting "Warning: Session_start() [function.session-start]" Error. Pls Help by Nobody: 12:29am On Jul 21, 2014 |
ob_start() is just a walkaround, but in most cases, call your PHP Scripts and Sessions before any HTML. Although ob_start() should fix it. But <?php ob_flush(); //ob_flush first to flush previous cache ob_start(); //Start a new Buffer session_start(); //call the session ?> |
Re: I'm Getting "Warning: Session_start() [function.session-start]" Error. Pls Help by Nobody: 12:39am On Jul 21, 2014 |
Ok, thanks Will give it a try |
Re: I'm Getting "Warning: Session_start() [function.session-start]" Error. Pls Help by dignityonly: 12:41am On Jul 21, 2014 |
coolsix: ob_start() is just a walkaround, but in most cases, call your PHP Scripts and Sessions before any HTML.
|
Re: I'm Getting "Warning: Session_start() [function.session-start]" Error. Pls Help by Nobody: 12:47am On Jul 21, 2014 |
The issue still seem to persist and this error appears only in the admin end. The user end do not have such error. |
Re: I'm Getting "Warning: Session_start() [function.session-start]" Error. Pls Help by dhtml(m): 1:41am On Jul 21, 2014 |
@op, please make sure there is no hidden space before you op start e.g. you can start like this just to be sure. <?php session_start();?> If all these dont work, then tire ti ba o ni yen (your village people don catch up with you) - just kidding. You can come back for advice, i will give you another approach which has never failed me so far. |
Re: I'm Getting "Warning: Session_start() [function.session-start]" Error. Pls Help by maekhel(m): 1:43am On Jul 21, 2014 |
make sure u are using session_start before any HTML request is sent |
Re: I'm Getting "Warning: Session_start() [function.session-start]" Error. Pls Help by Nobody: 2:50am On Jul 21, 2014 |
Depending on your server PHP settings at php.ini , ob_start() is sometimes disabled so it looks like its not working. Make use of ob_get_status(); Returns true; if enabled and false; if disabled. So if false; you may want to customize some php.ini in /usr/bin/php/php.ini you can use ini_get('ob_start', 'On'); //Turns it on (Requires root- Safe Mode off) or Manually edit .ini and turn it on. ----------------------------------- If you cannot still use your session... after all these.... oga. #Surulere |
Re: I'm Getting "Warning: Session_start() [function.session-start]" Error. Pls Help by Nobody: 2:51am On Jul 21, 2014 |
maekhel: make sure u are using session_start before any HTML request is sent session_start() can be used after HTML as long as there is <?php ob_start(); ?> or <?php ob_flush(); ?> at the top of the script |
Re: I'm Getting "Warning: Session_start() [function.session-start]" Error. Pls Help by dhtml(m): 6:21am On Jul 21, 2014 |
coolsix:True, i am suspecting that the op has an extra space before that ob_start. |
Re: I'm Getting "Warning: Session_start() [function.session-start]" Error. Pls Help by Kingsonly: 8:53am On Jul 21, 2014 |
<?php session_start(); if($_SESSION['myusername']==""{ header("location:index.php" } if(!$_SESSION){ header("location:index.php" } $usname=$_SESSION['myusername']; ?> "location:index.php" is space conscious so all you need to do is remove any space close to the code and make sure its the first line on each page, that should do the trick or copy my code and replace with yours |
(1) (Reply)
Escrow.com And Nigeria / Google Adsense Cheque / Isn't It Unbelievable That Thehackernews.com Is On Blogger?
(Go Up)
Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 23 |