Page 1 of 1

Parse error

Posted: Mon Dec 14, 2009 3:58 am
by aravona
I've been away from php / sql for about 4 months and am now working with someone elses code.

I'm able to use the code live but want to work and test the code whilst on a WAMP server on a laptop so that I don't inadvertently muck up the live site.

I have a 2.5k line long class function file which is giving me the following error:


Parse error: parse error in D:\wamp\www\_____________\lib\class-functions.php on line 2596

I have been thrown into this code a bit and have tried the obvious ( ; and missing } around that line) but its giving me the error for the final few lines:

Code: Select all

    $lastChar=substr($NAME,strlen($NAME)-1,strlen($NAME)-1);
    if($lastChar=='-'){
        $NAME=substr($NAME,0,strlen($NAME)-2);
    }
    return $NAME;
}////end of function
}//end of class 
?> [color=#BF0000]<-- this is line 2596 (which makes me think its something with the line above)[/color]
Having a bit of a brain freeze now and need this to run or I cant connect to the DB and test my changes, any thoughts?

Thanks

Re: Parse error

Posted: Mon Dec 14, 2009 4:13 am
by papa
Maybe a good time to refactor your code a bit. :)

Maybe I'm missing something obvious but please paste your entire function.

Re: Parse error

Posted: Mon Dec 14, 2009 4:17 am
by aravona
I don't think the problem is with any of the functions they seem to work when live. And there are a fair few. Heres the last for you though:

Code: Select all

 
function ReplaceSpaces($name){
    $NAME=strtolower($name);
    $EXP=explode("(",$NAME);
    if(sizeof($EXP)>1){
        $NAME=substr($EXP[0],0,strlen($EXP[0])-1);  
    }else{
        $NAME=$EXP[0];  
    }
    
    
    $NAME=str_replace(" ","-",$NAME);
    $NAME=str_replace("/","-",$NAME);
    $NAME=str_replace("'","-",$NAME);
    $NAME=str_replace("&","-",$NAME);
    $NAME=str_replace("&","-",$NAME);
    $NAME=str_replace("amp;","-",$NAME);
    $NAME=str_replace(" ","-",$NAME);
    $NAME=str_replace("'","-",$NAME);
    $NAME=str_replace("`","-",$NAME);
    $NAME=str_replace("`","-",$NAME);
    $NAME=str_replace("’","-",$NAME);
    $NAME=str_replace("-----","-",$NAME);
    $NAME=str_replace("----","-",$NAME);
    $NAME=str_replace("---","-",$NAME);
    $NAME=str_replace("--","-",$NAME);
    $NAME=str_replace("--","-",$NAME);
    $NAME=str_replace("--","-",$NAME);
    $NAME=str_replace("--","-",$NAME);
    $NAME=str_replace(",","",$NAME);
    $NAME=str_replace('&rdquo;','',$NAME);
    $NAME=str_replace('”','',$NAME);
    
 
    $lastChar=substr($NAME,strlen($NAME)-1,strlen($NAME)-1);
    if($lastChar=='-'){
        $NAME=substr($NAME,0,strlen($NAME)-2);
    }
    return $NAME;
}////end of function
 
 
 
}//end of class
?> [color=#BF0000]<-- this line gives the error[/color]