russia5 Posted February 7, 2007 Share Posted February 7, 2007 I uploaded my script into two different folders on my site. I then got a "Headers already sent erorr" I then deleted one of the scripts. I am still getting the error. Does anyone have a guess why? This is index.php <?php include ('book_sc_fns.php'); // The shopping cart needs sessions, so start one session_start(); do_html_header('Welcome to Book-O-Rama'); echo '<p>Please choose a category:</p>'; // get categories out of database $cat_array = get_categories(); // display as links to cat pages display_categories($cat_array); // if logged in as admin, show add, delete, edit cat links if(isset($_SESSION['admin_user'])) { display_button('admin.php', 'admin-menu', 'Admin Menu'); } do_html_footer(); ?> This is book_sc_fns.php <?php include_once('db_fns.php'); include_once('data_valid_fns.php'); include_once('output_fns.php'); include_once('book_fns.php'); include_once('user_auth_fns.php'); include_once('admin_fns.php'); include_once('order_fns.php'); ?> And here is the error on the page that was produced: Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /home/russia5/public_html/27/db_fns.php:24) in /home/russia5/public_html/27/index.php on line 4 Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/russia5/public_html/27/db_fns.php:24) in /home/russia5/public_html/27/index.php on line 4 Link to comment https://forums.phpfreaks.com/topic/37501-headers-already-sent-but-how/ Share on other sites More sharing options...
Balmung-San Posted February 7, 2007 Share Posted February 7, 2007 We need to see db_fns.php. That's where the error is occuring. Link to comment https://forums.phpfreaks.com/topic/37501-headers-already-sent-but-how/#findComment-179342 Share on other sites More sharing options...
russia5 Posted February 7, 2007 Author Share Posted February 7, 2007 Yes indeed! Here it is. <?php function db_connect() { $result = mysql_connect("localhost", "abc_usrid", "password"); mysql_select_db("booksc"); if (!$result) return false; return $result; } function db_result_to_array($result) { $res_array = array(); for ($count=0; $row = $result->fetch_assoc(); $count++) $res_array[$count] = $row; return $res_array; } ?> Link to comment https://forums.phpfreaks.com/topic/37501-headers-already-sent-but-how/#findComment-179346 Share on other sites More sharing options...
Balmung-San Posted February 7, 2007 Share Posted February 7, 2007 Try placing the session_start() above the include(). Link to comment https://forums.phpfreaks.com/topic/37501-headers-already-sent-but-how/#findComment-179347 Share on other sites More sharing options...
alpine Posted February 7, 2007 Share Posted February 7, 2007 You cannot have any whitespace, lines or other output to the browser before the php start-tag OK: ------------------------------------------------------------------ <?php session_start(); ERROR: ------------------------------------------------------------------ <?php session_start(); Means it's ok to put session_start() 'anyhwhere' as long as no output is done before it. Link to comment https://forums.phpfreaks.com/topic/37501-headers-already-sent-but-how/#findComment-179349 Share on other sites More sharing options...
russia5 Posted February 7, 2007 Author Share Posted February 7, 2007 Thankyou very much! That worked! Link to comment https://forums.phpfreaks.com/topic/37501-headers-already-sent-but-how/#findComment-179373 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.