SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Addict
    Join Date
    Jan 2005
    Location
    nyc
    Posts
    223
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    script works on all servers, but one!! loosing my hair!

    Hi all

    This problem is driving me crazy:
    I have a PHP script, that I tested on three servers:
    My local testing PHP server installed on my computer, and Two different remote hosting servers that support recent versions of PHP.

    The script works on my local server, and on one of the remote servers but Not on the other.
    The two servers where it works, are Apache servers. The server where it does not work, is a Windows server with PHP installed.
    I'm pretty sure it's not a PHP version issue, because my script is very basic, and the windows server has PHP 4.5 or something recent like that.
    Why on earth could this script fail in that particular server?

    You can see exactly what's not working by visiting this page (where it works):
    webtrans1.com/menu/menu.php

    and this page (where it doesn't work):
    maparchitects.com/site/test.php

    what IS WORKING in the first page, is that whenever you click on the PLUS or MINUS sign of any menu, the menu expends and retract. That's good.

    What is NOT WORKING in the second page, is that when you click on the PLUS, the menu expends, but then if you click again on the same, it does not retract. The open menu won't retract unless you click on a DIFFERENT menu option. That's bad.

    Please help me.

    here's the whole code for this menu:


    PHP Code:
    <?php
    $pages 
    'pages/';
    $page 'portfolio/';

    if (!empty(
    $_GET['sec'])){
        
    $section $_GET['sec'];
    }
    if (!empty(
    $_GET['sub'])){
        
    $sub_section $_GET['sub'];
    }
    if (!empty(
    $_GET['pro'])){
        
    $project urldecode($_GET['pro']);
    }
    ?>
    <link href="menu/newmenu.css" rel="stylesheet" type="text/css">
    <div style="position:relative; width:160px;">
        <div id="Layer1" style="position:absolute; left:0px; top:0px; width:131px; height:483px; z-index:1; padding: 0; background-color: #BE3038; overflow:hidden;">
            <div style="position:relative; height:47px; padding:0; margin:0;"></div>
    <?php
    $t 
    0;
    $bt 0;
    $st 0;
    $selected ' class="topdiv"';
    $subselected ' class="sub"';

    $gbt $_GET['bt'];
    $gt $_GET['tab'];
    $gst $_GET['st'];

    $gbig_1 $_GET['big_1'];
    $gbig_2 $_GET['big_2'];
    $gbig_3 $_GET['big_3'];
    $gbig_4 $_GET['big_4'];
    $gs1 $_GET['s1'];
    $gs2 $_GET['s2'];
    $gs3 $_GET['s3'];
    $gs4 $_GET['s4'];

    function 
    big_plus_minus($you){
        global 
    $t$gt$bt$gbt$selected;
        if (
    $t == $gt){
            if (
    $bt == $gbt){
                if (
    $you == 'minus'){
                    
    $you 'plus';
                }else{
                    
    $you 'minus';
                }
            }else{
                
    $you 'minus';
                
    $selected ' class="selected"';
            }
        }else{
            
    $you 'plus';
            
    $selected ' class="topdiv"';
        }
        return 
    $you;
    }

    function 
    plus_minus($you){
        global 
    $st$gst$subselected;
        if (
    $st == $gst){
            if (
    $you == 'minus'){
                
    $you 'plus';
            }else{
                
    $you 'minus';
                
    $subselected ' class="subselected"';
            }
        }else{
            
    $you 'plus';
            
    $subselected ' class="sub"';
        }
        return 
    $you;
    }
    $id 0;
    $gid $_GET['id'];
    // CREATES THE CODE FOR EACH DIV IN THE SUB LISTS
    function div($name){    
        global 
    $se,$su,$t$st$gid$id;
        ++
    $id;
        echo 
    '<div class="subsub"';
        if (
    $id == $gid){
            echo
    'style="background-color:#FFFFFF;"';
        }
        echo 
    '><a href="'.$PHP_SELF.'?sec='.$se.'&sub='.$su.'&pro='
        
    $url_name urlencode($name.'/');
        echo 
    $url_name;
        echo 
    '&abt='.$t.'&st='.$st.'&id='.$id.'"';
        if (
    $id == $gid){
            echo
    'style="color:#000000;"';
        } 
        echo
    '>'.ucwords($name).'</a></div>';
    }

    //GETS THE LIST OF FOLDERS (PROJECT) AND CREATES A DIV (USING THE div(); FUNCTION ABOVE) FOR EACH FOLDER/PROJECT
    function subdivs(){
        global 
    $pages,$page,$se,$su;
        
    $section urldecode($se);
        
    $sub urldecode($su);
        
    $path $pages.$page.$section.$sub;
        if (
    $handle opendir($path)) {
            while (
    false !== ($dir readdir($handle))) { 
                if (
    $dir != '.' && $dir != '..' && $dir != 'meta') {
                    if (
    is_dir($path.$dir)) {
                        
    $folders[]=$dir;
                    }
                }
            }
            
    closedir($handle);
            if (
    count($folders)) {
                foreach (
    $folders as $fold) {
                    
    div($fold);
                }
            }
        }
    }

    ++
    $bt;
    ++
    $t;
    $big_1 big_plus_minus($big_1);
    echo 
    '<div'; echo $selected; echo'><a href="'.$PHP_SELF.'?tab='.$t.'&bt='.$bt.'&big_1='.$big_1.'"><img src="menu/images/'.$big_1.'.gif" height="13" width="13" border="0" align="left"></a><a href="'.$PHP_SELF.'?sec='$se urlencode('housing/'); echo $se.'&bt='.$bt.'">Housing</a></div>';
    if (
    $big_1 == 'minus'){
        ++
    $st;
        
    $s1 plus_minus($s1);
        echo 
    '<div';echo $subselected; echo'><a href="'.$PHP_SELF.'?tab='.$t.'&st='.$st.'&bt='.$bt.'&s1='.$s1.'"><img src="menu/images/'.$s1.'.gif" height="13" width="13" border="0" align="left"></a><a href="'.$PHP_SELF.'?sec='.$se.'&sub='$su urlencode('mixed-use/'); echo $su.'&t='.$t.'&sub_t='.$bt.'">Mixed-use</a></div>';
        if (
    $s1 == 'minus'){subdivs();}
        ++
    $st;
        
    $s2 plus_minus($s2);
        echo 
    '<div'; echo $subselected; echo '><a href="'.$PHP_SELF.'?tab='.$t.'&st='.$st.'&bt='.$bt.'&s2='.$s2.'"><img src="menu/images/'.$s2.'.gif" height="13" width="13" border="0" align="left"></a><a href="'.$PHP_SELF.'?sec='.$se.'&sub='$su urlencode('townhouses/'); echo $su.'&t='.$t.'&sub_t='.$bt.'">Townhouses</a></div>';
        if (
    $s2 == 'minus'){subdivs();}
        ++
    $st;
        
    $s3 plus_minus($s3);
        echo 
    '<div'; echo $subselected; echo '><a href="'.$PHP_SELF.'?tab='.$t.'&st='.$st.'&bt='.$bt.'&s3='.$s3.'"><img src="menu/images/'.$s3.'.gif" height="13" width="13" border="0" align="left"></a><a href="'.$PHP_SELF.'?sec='.$se.'&sub='$su urlencode('affordable housing/'); echo $su.'&t='.$t.'&sub_t='.$bt.'">Affordable Housing</a></div>';
        if (
    $s3 == 'minus'){subdivs();}
        ++
    $st;
        
    $s4 plus_minus($s4);
        echo 
    '<div'; echo $subselected; echo '><a href="'.$PHP_SELF.'?tab='.$t.'&st='.$st.'&bt='.$bt.'&s4='.$s4.'"><img src="menu/images/'.$s4.'.gif" height="13" width="13" border="0" align="left"></a><a href="'.$PHP_SELF.'?sec='.$se.'&sub='$su urlencode('senior housing/'); echo $su.'&t='.$t.'&sub_t='.$bt.'">Senior Housing</a></div>';
        if (
    $s4 == 'minus'){subdivs();}
    }
    $su '';
    ++
    $bt;
    ++
    $t;
    $big_2 big_plus_minus($big_2);
    echo 
    '<div'; echo $selected; echo '><a href="'.$PHP_SELF.'?t='.$t.'&bt='.$bt.'&big_2='.$big_2.'"><img src="menu/images/'.$big_2.'.gif" height="13" width="13" border="0" align="left"></a><a href="'.$PHP_SELF.'?sec='$se urlencode('education/'); echo $se.'">Education</a></div>';
    if (
    $big_2 == 'minus'){subdivs();}
    ++
    $bt;
    ++
    $t;
    $big_3 big_plus_minus($big_3);
    echo 
    '<div'; echo $selected; echo '><a href="'.$PHP_SELF.'?t='.$t.'&bt='.$bt.'&big_3='.$big_3.'"><img src="menu/images/'.$big_3.'.gif" height="13" width="13" border="0" align="left"></a><a href="'.$PHP_SELF.'?sec='$se urlencode('planning/'); echo $se.'">Planning</a></div>';
    if (
    $big_3 == 'minus'){subdivs();}
    ++
    $bt;
    ++
    $t;
    $big_4 big_plus_minus($big_4);
    echo 
    '<div'; echo $selected; echo '><a href="'.$PHP_SELF.'?t='.$t.'&bt='.$bt.'&big_4='.$big_4.'"><img src="menu/images/'.$big_4.'.gif" height="13" width="13" border="0" align="left"></a><a href="'.$PHP_SELF.'?sec='$se urlencode('community health/'); echo $se.'">Community Health</a></div>';
    if (
    $big_4 == 'minus'){subdivs();}
    ?>
        </div>
    </div>

  2. #2
    SitePoint Addict
    Join Date
    Jan 2005
    Location
    nyc
    Posts
    223
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    well my thread didn't attract lots of interest, but anyways I finaly figured out the problem, so I figure I'll let other PHP amateurs share my findings:
    The script doesn't work because register_globals is tunred OFF on the windows server. Other scripts that use global variables in functions do work on that same server because they don't reload the page.
    But this scripts reloads the page, and passes the global variable via url encoded strings, BUT register_global when turned OFF destroys the global variables when the page is reloaded.

    Now I have to figure out how to re-write this script that heavily relied on global vars. Maybe by using sessions instead (but I'll have to create about 15 different cookies for that, which might be a problem also...)

    Thank you all anyways


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
  •