473,396 Members | 1,929 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

"Cannot modify header information" error

mikek12004
200 100+
In top of my index I include funcs.php which is :
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. function GetCartId()
  3. {
  4.     //if user logged on use username as identification, else use coockie for anonymous user    
  5.     if ($_SESSION['loggedon']==1)
  6.     {
  7.     $a=$_SESSION['username'];
  8.     }            
  9.     else
  10.     {
  11.     // This part generates an encrypted string and will set it as a cookie using set_cookie. This will also be used as the cookieId    //field in the cart table
  12.         if(isset($_COOKIE["cartId"]))
  13.         {
  14.             return $_COOKIE["cartId"];
  15.         }
  16.         else
  17.         {
  18.             // There is no cookie set. We will set the cookie
  19.             // and return the value of the users session ID
  20.  
  21.             session_start();
  22.             setcookie("cartId", session_id(), time() + ((3600 * 24) * 30));
  23.             $a=session_id();
  24.  
  25.  
  26.         }
  27.     }
  28.     return $a;
  29. }
  30. function mssql_sec($a)
  31. {
  32. $a=str_replace("'","''",$a);
  33. $a=str_replace(";","",$a);
  34. return $a;
  35. }
  36. function mssql_sec2($a)
  37. {
  38. $a=str_replace("'","''",$a);
  39. //$a=str_replace(";","",$a);
  40. return $a;
  41. }
  42. ?>
  43.  
then later at the index I include basket.php which calls GetCartId() and the explorer shows the message
"Cannot modify header information - headers already sent by (output started at /var/www/html/generalm/demo/index.php:31) in /var/www/html/generalm/demo/nimda/funcs.php on line 22"
any help?
PS before including the funcs.php I have sesion_start()
Oct 21 '08 #1
1 1315
mikek12004
200 100+
The whole point is to identify a user so I can recognise him in future visits, even if I get the error the func works and a unique id (which is $a) is retrived which I can use it to display various info for him, any idea how can I disable the stupid error and why since it works this error is diplayed?
Oct 21 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: beliavsky | last post by:
Ideally, one can use someone's C++ code by just looking at the header files (which should contain comments describing the functions in addition to function definitions), without access to the full...
1
by: Chris | last post by:
I built small C# Web and Web Service applications in a training class last week. The applications worked in the class, but when I tried to run them again over the weekend, they both bombed....
5
by: Francis Shanahan | last post by:
Folks, I have a base page which is the grand-daddy of all my pages. It inherits from System.UI.Web.Page From this I inherit a layout page. From this I inherit the individual pages themselves....
6
by: Aaron Smith | last post by:
Ok. I have a dataset that has multiple tables in it. In one of the child tables, I have a column that I added to the DataSet (Not in the DataSource). This column does not need to be stored in the...
5
by: Chris Robb | last post by:
I'm having some really odd behavior with a PHP script. I have it populating an HTML select form with a for loop. When I try the years 2006 to 1900. I get the following error: PHP Warning: ...
1
by: stillh2os | last post by:
Hello. I'm new to .NET, and I'm trying to implement a callback function. I want my managed C++ code to call an unmanaged function, passing in a callback function that the unmanaged C/C++ code...
3
luke14free
by: luke14free | last post by:
Do you know why do I get that message when i type a normal setcookie function?? Warning: Cannot modify header information - headers already sent by (output started at...
4
by: GHUM | last post by:
The compile works, BUT linking fails: 2.5\Release\psycopg\_psycopg.def -Lc:\python25\libs -Lc: \python25\PCBuild -Lc:/p ostgres/83RC2/lib -lpython25 -lpq -lws2_32 -ladvapi32 -o build...
3
by: K Viltersten | last post by:
I've been informed that a webserver sending a XML file is supposed to add "Content-Type: text/xml header". I'm not questioning that infromation but i'm unsure what was ment by it. The XML i get...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.