SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Zealot pavanpuligandla's Avatar
    Join Date
    Sep 2008
    Location
    hyderabad
    Posts
    179
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    php sessions problem on IIS webserver under pleskpanel

    hii all,
    i'm working on a smal database driven music shop site, with shopping cart feature..
    its working with no issues on my localhost, when i upload it to my domain, i'm getting problem with sessions.
    heres my url(http://www.veeturi.com/onlinestore/)
    i'm getting warning :headers already sent, cannot modify header information error.

    can anyone pls help me out..
    i'll supply my source files if needed for further assistance..

    many thanks,
    PHP Professional turned ASP.NET Professional

  2. #2
    SitePoint Addict hiddenpearls's Avatar
    Join Date
    Dec 2007
    Location
    Pakistan
    Posts
    262
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No , not the problem with IIS ,
    u just need to remove the spaces before the headers are directed.

  3. #3
    SitePoint Zealot pavanpuligandla's Avatar
    Join Date
    Sep 2008
    Location
    hyderabad
    Posts
    179
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    u just need to remove the spaces before the headers are directed.
    yeah, there are no white spaces before the headers are sent.
    but theres some php code content before those headers,
    here's the code:

    Code:
    if (isset($_GET["shopping_cart"]) || isset($_POST["shopping_cart"]))
    	{
    		if (isset($_GET["add2cart"]) && $_GET["add2cart"]>0) //add product to cart with productID=$add
    		{
    			$q = db_query("select in_stock from ".PRODUCTS_TABLE." where productID='".$_GET["add2cart"]."'") or die (db_error());
    			$is = db_fetch_row($q); $is = $is[0];
    			//$_SESSION[gids] contains product IDs
    			//$_SESSION[counts] contains product quantities ($_SESSION[counts][$i] corresponds to $_SESSION[gids][$i])
    			//$_SESSION[gids][$i] == 0 means $i-element is 'empty'
    			if (!isset($_SESSION["gids"]))
    			{
    				$_SESSION["gids"] = array();
    				$_SESSION["counts"] = array();
    			}
    			//check for current item in the current shopping cart content
    			$i=0;
    			while ($i<count($_SESSION["gids"]) && $_SESSION["gids"][$i] != $_GET["add2cart"]) $i++;
    			if ($i < count($_SESSION["gids"])) //increase current product's quantity
    			{
    				$_SESSION["counts"][$i]++;
    			}
    			else //no item - add it to $gids array
    			{
    				$_SESSION["gids"][] = $_GET["add2cart"];
    				$_SESSION["counts"][] = 1;
    			}
    			header("Location: index.php?shopping_cart=yes");
    		}
    even i've tried with include and require instead of sending headers,
    i'm getting no include and require functions exist in the specified directory error.
    can you please check the code.
    many thanks for comeback,
    PHP Professional turned ASP.NET Professional

  4. #4
    SitePoint Addict hiddenpearls's Avatar
    Join Date
    Dec 2007
    Location
    Pakistan
    Posts
    262
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    there should not be any echo before header redirection !

  5. #5
    SitePoint Zealot pavanpuligandla's Avatar
    Join Date
    Sep 2008
    Location
    hyderabad
    Posts
    179
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    okay,
    wht should i do now?
    no use of trying with include and require..
    wht would you suggest?
    PHP Professional turned ASP.NET Professional

  6. #6
    SitePoint Addict hiddenpearls's Avatar
    Join Date
    Dec 2007
    Location
    Pakistan
    Posts
    262
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    what i have used in my experience is :

    - no spaces before header();
    - no echos
    - take a narrow look , do step by step checking of error in lines
    - remove everything on that page and then check by adding one line and then check again by adding one more line , in this way u can debug it easily .


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •