• Hi all,

    I’m trying to modify a PHP / JS script to detect the users screen size and set a variable accordingly but I seem to have hit a snag and nobody on codingforums.com can help me with it :/

    I was hoping that someone here might have some insight
    here’s the thread if it helps:
    http://www.codingforums.com/showthread.php?t=144521&page=2

    and here’s the code:

    <script type="text/javascript">
    function nextpage(currlang){
       var url = 'http://www.gryphondor.com?&w=' + screen.width;
       window.location.href = url;
    
    }
    </script>

    and here’s the PHP`
    <?php

    /* I pass directly the GET to the variables but you must check
    * first if are safe using some code you want. For example I
    * would restrict $lang to be only ‘fr’ and ‘en’ and w to be a positive non-zero integer
    */

    $w = $_GET[‘w’];
    // and now select the apropriate dir for your resolution
    // first the default, for unexpected values of $w
    $wpdir = ‘wallpapers’;
    if($w == 800){
    $wpdir .= ‘800’;
    }elseif($w == 1024){
    $wpdir .= ‘1024’;
    }elseif($w == 1152){
    $wpdir .= ‘1152’;
    }elseif($w == 1280){
    $wpdir .= ‘1280’;
    }elseif($w == 1600){
    $wpdir .= ‘1600’;
    }
    // here $wpdir will be ‘wallpapers800’ for example

    $wpdir .= ‘/’;

    // constant are really constant, 🙂 so you must define the dirs
    // where you have the wallpapers as constant
    define(‘VL_WALLPAPER_DIR’, $wpdir); `

    and here’s the error i get:
    session_start() [function.session-start]: Cannot send session cache limiter – headers already sent (output started at /mnt/local/home/gryphondor/gryphondor.com/wp-content/themes/vistered-little/wallpaper_functions.php:53) in /mnt/local/home/gryphondor/gryphondor.com/wp-content/themes/vistered-little/wallpaper_functions.php on line 86

    Any idea why / how I can fix this?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter canadianjameson

    (@canadianjameson)

    let me try to place the PHP in code brackets again:

    <?php
    
    /* I pass directly the GET to the variables but you must check
    * first if are safe using some code you want. For example I
    * would restrict $lang to be only 'fr' and 'en' and w to be a positive non-zero integer
    */
    
    $w = $_GET['w'];
    // and now select the apropriate dir for your resolution
    // first the default, for unexpected values of $w
    $wpdir = 'wallpapers';
    if($w == 800){
    $wpdir .= '800';
    }elseif($w == 1024){
    $wpdir .= '1024';
    }elseif($w == 1152){
    $wpdir .= '1152';
    }elseif($w == 1280){
    $wpdir .= '1280';
    }elseif($w == 1600){
    $wpdir .= '1600';
    }
    // here $wpdir will be 'wallpapers800' for example
    
    $wpdir .= '/';
    
    // constant are really constant, :) so you must define the dirs
    // where you have the wallpapers as constant
    define('VL_WALLPAPER_DIR', $wpdir);

    Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    session_start() [function.session-start]: Cannot send session cache limiter – headers already sent (output started at /mnt/local/home/gryphondor/gryphondor.com/wp-content/themes/vistered-little/wallpaper_functions.php:53) in /mnt/local/home/gryphondor/gryphondor.com/wp-content/themes/vistered-little/wallpaper_functions.php on line 86

    It looks like your file is sending some kind of output before it tries to start the session, which you can’t do.

    Post the entire file over on http://wordpress.pastebin.ca and post the link back here, so we can take a look at it.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘getting error: session_start() [function.session-start]: Cannot send session …’ is closed to new replies.