SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    SitePoint Enthusiast
    Join Date
    Jun 2011
    Posts
    74
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Headers not working live

    Works perfectly on localhost but wont redirect live.
    The redirect function is

    PHP Code:
    function redirect_to($location NULL){
        if (
    $location != NULL) {
            
    header("Location: {$location}");
            exit;
        }

    and one of the pages not working is

    PHP Code:
    <?php 
        $pid 
    $_POST['id'];
        
    $q $_POST['qty'];

        
    // if($pid<1 or $q<1) return;
     
        
    if(is_array($_SESSION['cart'])){
            
    // if(product_exists($pid)) return;
            
    if(product_exists($pid)){
                
    $max=count($_SESSION['cart']);
                for(
    $i=0;$i<$max;$i++){
                    if(
    $_SESSION['cart'][$i]['productid'] == $pid){
                        
    $_SESSION['cart'][$i]['qty'] = $_SESSION['cart'][$i]['qty'] + $q;
                    }
                }
            }else{
                
    $max=count($_SESSION['cart']);
                
    $_SESSION['cart'][$max]['productid']=$pid;
                
    $_SESSION['cart'][$max]['qty']=$q;
            }        
        }
        else{
            
    $_SESSION['cart']=array();
            
    $_SESSION['cart'][0]['productid']=$pid;
            
    $_SESSION['cart'][0]['qty']=$q;
        }
        
    redirect_to("viewcart.html");
    ?>
    Thanks in advance for the help

  2. #2
    SitePoint Wizard lorenw's Avatar
    Join Date
    Feb 2005
    Location
    was rainy Oregon now sunny Florida
    Posts
    1,104
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    On the live server tun on error reporting or add this bit to the top of you're script.
    Code:
    ini_set("error_reporting", E_ALL ^ E_NOTICE); 
    ini_set("display_errors", 1);
    I suspect that headers have been sent meaning that there is white space or a BOM being sent before the header redirect.
    What I lack in acuracy I make up for in misteaks

  3. #3
    SitePoint Enthusiast
    Join Date
    Jun 2011
    Posts
    74
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Cheers that was it. Been a while since doing php on a live server totally forgot about that stuff

    Thanks


Tags for this Thread

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
  •