Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    THM
    THM is offline
    New Coder
    Join Date
    Jun 2006
    Location
    Philladelphia
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    unexpected T_ELSE Error and Need help

    I'm working on a script and trying to make it where, if an imposter tries to post as an admin or mod they get an error. But i still want other members to be able to post and get through. So i did, ($nick != $mod) to say that its not equal to the user it can go through. However, i keep getting Parse error: parse error, unexpected T_ELSE on the line 167. Which would be else if ($REMOTE_ADDR == $modip). Most likely, this is a newbie problem since this is my first code i am writing, but i was wondering if anyone out there could help me. Thanks alot to everyone who can provide even the littlest help

    PHP Code:
    if ($nick != $mod)
            echo 
    "<META HTTP-EQUIV=\"REFRESH\" CONTENT=\"3; URL=tagboard.php\">";
            echo 
    "$beginning.Hello $nick.$ending";
            
    $ff_input "$nick%%$message@@" "##$REMOTE_ADDR\n" $output;
            
    $s fopen($shouts"w");
            
    fwrite($sstripslashes($ff_input));
            
    fclose($s);
            

           else if (
    $REMOTE_ADDR == $modip)
               echo 
    "<META HTTP-EQUIV=\"REFRESH\" CONTENT=\"3; URL=tagboard.php\">";
               echo 
    "$beginning.Hello $mod.$ending";
            
    $ff_input "$nick%%$message@@" "##$REMOTE_ADDR\n" $output;
            
    $s fopen($shouts"w");
            
    fwrite($sstripslashes($ff_input));
            
    fclose($s);
           
             else
               echo 
    "$beginning$imposter";
               if (
    $trackonvoid == on)
               
    $ff_input "MSG/$message" "IP/$REMOTE_ADDR\n" $output;
               
    $s fopen($mimp"w");
               
    fwrite($sstripslashes($ff_input));
               
    fclose($s); 
           } 

  • #2
    Regular Coder PremiumBlend's Avatar
    Join Date
    Apr 2006
    Location
    Marion, Iowa
    Posts
    201
    Thanks
    0
    Thanked 13 Times in 13 Posts
    It appears to be a structure problem. It looks like you have 3 conditions and 3 blocks of code to execute, if that is true, you just need curly braces. Give this a try:

    PHP Code:
    if ($nick != $mod) {
            echo 
    "<META HTTP-EQUIV=\"REFRESH\" CONTENT=\"3; URL=tagboard.php\">";
            echo 
    "$beginning.Hello $nick.$ending";
            
    $ff_input "$nick%%$message@@" "##$REMOTE_ADDR\n" $output;
            
    $s fopen($shouts"w");
            
    fwrite($sstripslashes($ff_input));
            
    fclose($s);
    } else if (
    $REMOTE_ADDR == $modip) {
               echo 
    "<META HTTP-EQUIV=\"REFRESH\" CONTENT=\"3; URL=tagboard.php\">";
               echo 
    "$beginning.Hello $mod.$ending";
            
    $ff_input "$nick%%$message@@" "##$REMOTE_ADDR\n" $output;
            
    $s fopen($shouts"w");
            
    fwrite($sstripslashes($ff_input));
            
    fclose($s);
    } else {
               echo 
    "$beginning$imposter";
               if (
    $trackonvoid == on)
               
    $ff_input "MSG/$message" "IP/$REMOTE_ADDR\n" $output;
               
    $s fopen($mimp"w");
               
    fwrite($sstripslashes($ff_input));
               
    fclose($s); 

    My Website: DumpsterDoggy

  • #3
    THM
    THM is offline
    New Coder
    Join Date
    Jun 2006
    Location
    Philladelphia
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts
    ok. now i added that, and i'm getting this...


    Parse error: parse error, unexpected $ on line 184
    PHP Code:
    ?> 
    Thats all thats on line 184... So? Any ideas?

    Thanks for your help above though. It stopped the errors with that part.

  • #4
    Regular Coder PremiumBlend's Avatar
    Join Date
    Apr 2006
    Location
    Marion, Iowa
    Posts
    201
    Thanks
    0
    Thanked 13 Times in 13 Posts
    I'm not sure because I can't see all 184 lines. Most times when parsers find errors, the error won't be reported until later, so your line:

    PHP Code:
    ?> 
    isn't the problem, its going to be the line above it on an error such as that.

    I'm not the best in PHP, but post all of your code, maybe I can help you out with the errors.
    My Website: DumpsterDoggy

  • #5
    THM
    THM is offline
    New Coder
    Join Date
    Jun 2006
    Location
    Philladelphia
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts
    PHP Code:
    <?

    require ("required.php");

    echo 
    "<HTML>\n";
    echo 
    "  <HEAD>\n";
    require (
    "copy.php");
    require (
    "css.php");
    echo 
    "  </HEAD>\n";
    echo 
    "  <BODY topmargin=\"2\" leftmargin=\"2\" bottommargin=\"2\" rightmargin=\"2\">\n";

    $beginning "<CENTER>";
    $ending    "<BR><BR><B><A href=\"tagboard.php\" target=\"tagboard\">Don't Feel like waiting to redirect? Click here!</A></B></CENTER>";

    if (
    $REQUEST_METHOD == "POST")
      

        if (
    strlen($nick) > $nicklength || strlen($message) > $messagelength || strlen($url) > $urllength )
          {
            echo 
    "<CENTER>$error_length<BR><BR><B><A href=\"tagboard.php\">Return</A></B></CENTER>";
            exit;
          }

          {
            
    $nick strip_tags ($nick);
            
    $url strip_tags ($url);
            
    $message strip_tags ($message);
          }


        
    $url trim($url);
      
        if ( !
    eregi("^(http://|ftp://)?(www\.)?([a-z0-9\.-])+(\.[a-z])+(:[0-9])?(/{1}[\.a-z0-9\+_-])*"$url) && $url != "" && $url != "http://" )
          {
            if (
    eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*$"$url))
              
    $url "mailto:" $url
            else
              {
                echo 
    $beginning "DUH." $ending;
                exit;
              }
          }
        else
          {
            if( !
    stristr($url"http://") && !stristr($url"ftp://") )
              
    $url "http://" $url;
          }


        if (
    $bigword == on)
          {
            
    $word_array split(" "$message);
            for(
    $i 0$i count($word_array); $i++)
              {
                if (
    strlen($word_array[$i]) > $maxword)
                  {
                    echo 
    "$beginning$error_wordlen$ending";
                    exit;
                  }
              }
          }


        if ( 
    $nick == "" || substr($nick04) == "nick" || trim($nick) == "" )
          {
            echo 
    "$beginning$error_nonick$ending";
            exit;
          }

        if ( 
    $message == "" || substr($message07) == "message" || trim($message) == "" )
          {
            echo 
    "$beginning$error_nomsg$ending";
            exit;
          }
          {
            if (
    $floodprotect == on)
              {
                
    $file_lines file($shouts);
                
    $how_many_times 0;
                
    $ip_addy  substr($file_lines[0], ((strpos($file_lines[0], "##")) + 2), ((strlen(substr($file_lines[0], ((strpos($file_lines[0], "##")) + 2)))) - 1));

                if (
    $REMOTE_ADDR == $ip_addy)
                  {

                    for (
    $i 0$i+<= $floodtotal$i++)
                      {
                        
    $ip_addy substr($file_lines[$i], (strpos($file_lines[$i], "##"))+2, (strlen(substr($file_lines[$i], ((strpos($file_lines[0], "##")) + 2)))) - 1);

                        if (
    $ip_addy == $REMOTE_ADDR)
                          {
                            
    $how_many_times++;

                            if (
    $how_many_times == $floodtotal)
                              {
                                echo 
    "$beginning$error_flood$ending";
                                exit;
                              }
                          }
                      }
                  }    
              }

            
    $output "";
            
    $file_lines file($shouts);

            foreach(
    $file_lines as $line
              
    $output .= $line;

            if (
    $url != "" && $url != "http://")
              {
                
    $nick "<A href=\"$url\" target=\"_blank\">$nick</A>";
              }


        if (
    $filter == on)
          {
            for (
    $i 0$i <= sizeof($keywords); $i++)
              {
                if (
    stristr($nick$keywords[$i]) || stristr($message$keywords[$i]))
                  {
                    
    $error str_replace("[KEYWORD]"$keywords[$i], $censored_notice);
                    echo 
    "$beginning$error";
                    
                  }
              }
          }


        
    /* THE M&A Part */
    if ($nick != $mod) { 
            echo 
    "<META HTTP-EQUIV=\"REFRESH\" CONTENT=\"3; URL=tagboard.php\">"
            echo 
    "$beginning.Hello $nick.$ending"
            
    $ff_input "$nick%%$message@@" "##$REMOTE_ADDR\n" $output
            
    $s fopen($shouts"w"); 
            
    fwrite($sstripslashes($ff_input)); 
            
    fclose($s); 
    } else if (
    $REMOTE_ADDR == $modip) { 
               echo 
    "<META HTTP-EQUIV=\"REFRESH\" CONTENT=\"3; URL=tagboard.php\">"
               echo 
    "$beginning.Hello $mod.$ending"
            
    $ff_input "$nick%%$message@@" "##$REMOTE_ADDR\n" $output
            
    $s fopen($shouts"w"); 
            
    fwrite($sstripslashes($ff_input)); 
            
    fclose($s); 
    } else { 
               echo 
    "$beginning$imposter"
               if (
    $trackonvoid == on
               
    $ff_input "MSG/$message" "IP/$REMOTE_ADDR\n" $output
               
    $s fopen($mimp"w"); 
               
    fwrite($sstripslashes($ff_input)); 
               
    fclose($s);  

         
    /* END M&A PART */
        
            
    $output "";
            
    $file_lines file($shouts);

            foreach(
    $file_lines as $line
              
    $output .= $line;

            if (
    $url != "" && $url != "http://")
              {
                
    $nick "<A href=\"$url\" target=\"_blank\">$nick</A>";
              }
            
    $ff_input "$nick%%$message@@" "##$REMOTE_ADDR\n" $output;
            
    $s fopen($shouts"w");
            
    fwrite($sstripslashes($ff_input));
            
    fclose($s);
        

        if (
    $emailnotify == on)
          
    mail($emailaddy$emailsubject$emailbody "From: $emailsig");



        echo 
    "    <META HTTP-EQUIV=\"REFRESH\" CONTENT=\"3; URL=tagboard.php\">\n";
        echo 
    "<center>";
        echo 
    "Redirecting...";
        echo 
    "$ending";
        echo 
    "</center>";
      }

    echo 
    "  </BODY>\n";
    echo 
    "</HTML>";
    ?>
    that ^ is the entire code...
    Last edited by THM; 06-21-2006 at 07:59 PM.

  • #6
    Regular Coder PremiumBlend's Avatar
    Join Date
    Apr 2006
    Location
    Marion, Iowa
    Posts
    201
    Thanks
    0
    Thanked 13 Times in 13 Posts
    It appears to be a curly brace problem again. Try structuring your code uniformly throughout the whole script and i'm sure you'll see the problems with the code before. Hopefully this code will work syntactically, but don't save over your original code for 2 reasons. One, mine might not work; two, you can compare whether it does or doesn't and see what was wrong. Hopefully you can learn from it.

    PHP Code:
    <?

    require ("required.php");

    echo 
    "<HTML>\n";
    echo 
    "  <HEAD>\n";
    require (
    "copy.php");
    require (
    "css.php");
    echo 
    "  </HEAD>\n";
    echo 
    "  <BODY topmargin=\"2\" leftmargin=\"2\" bottommargin=\"2\" rightmargin=\"2\">\n";

    $beginning "<CENTER>";
    $ending    "<BR><BR><B><A href=\"tagboard.php\" target=\"tagboard\">Don't Feel like waiting to redirect? Click here!</A></B></CENTER>";

    if (
    $REQUEST_METHOD == "POST")
    {
        if (
    strlen($nick) > $nicklength || strlen($message) > $messagelength || strlen($url) > $urllength ) {
            echo 
    "<CENTER>$error_length<BR><BR><B><A href=\"tagboard.php\">Return</A></B></CENTER>";
            exit;

        } else {
            
    $nick strip_tags ($nick);
            
    $url strip_tags ($url);
            
    $message strip_tags ($message);
        }

        
    $url trim($url);
      
        if ( !
    eregi("^(http://|ftp://)?(www\.)?([a-z0-9\.-])+(\.[a-z])+(:[0-9])?(/{1}[\.a-z0-9\+_-])*"$url) && $url != "" && $url != "http://" ) {
            if (
    eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*$"$url))
            
    $url "mailto:" $url

        } else {
            echo 
    $beginning "DUH." $ending;
            exit;
        }

    } else {
        if( !
    stristr($url"http://") && !stristr($url"ftp://") )
        
    $url "http://" $url;
    }

    if (
    $bigword == on) {
        
    $word_array split(" "$message);
        for(
    $i 0$i count($word_array); $i++) {
            if (
    strlen($word_array[$i]) > $maxword) {
                echo 
    "$beginning$error_wordlen$ending";
                exit;
            }
        }
    }

    if ( 
    $nick == "" || substr($nick04) == "nick" || trim($nick) == "" ) {
        echo 
    "$beginning$error_nonick$ending";
        exit;
    }

    if ( 
    $message == "" || substr($message07) == "message" || trim($message) == "" ) {
        echo 
    "$beginning$error_nomsg$ending";
        exit;
    }

    if (
    $floodprotect == on) {
        
    $file_lines file($shouts);
        
    $how_many_times 0;
        
    $ip_addy  substr($file_lines[0], ((strpos($file_lines[0], "##")) + 2), ((strlen(substr($file_lines[0], ((strpos($file_lines[0], "##")) + 2)))) - 1));

        if (
    $REMOTE_ADDR == $ip_addy) {

            for (
    $i 0$i+<= $floodtotal$i++) {
                
    $ip_addy substr($file_lines[$i], (strpos($file_lines[$i], "##"))+2, (strlen(substr($file_lines[$i], ((strpos($file_lines[0], "##")) + 2)))) - 1);

                if (
    $ip_addy == $REMOTE_ADDR) {
                    
    $how_many_times++;
                }

                if (
    $how_many_times == $floodtotal) {
                    echo 
    "$beginning$error_flood$ending";
                    exit;
                }
            }
        }    
    }


    $output "";
    $file_lines file($shouts);

    foreach(
    $file_lines as $line) {
        
    $output .= $line;
    }

    if (
    $url != "" && $url != "http://") {
        
    $nick "<A href=\"$url\" target=\"_blank\">$nick</A>";
    }


    if (
    $filter == on) {
        for (
    $i 0$i <= sizeof($keywords); $i++) {
            if (
    stristr($nick$keywords[$i]) || stristr($message$keywords[$i])) {
                
    $error str_replace("[KEYWORD]"$keywords[$i], $censored_notice);
                echo 
    "$beginning$error";
            }
        }
    }


        
    /* THE M&A Part */
    if ($nick != $mod) { 
        echo 
    "<META HTTP-EQUIV=\"REFRESH\" CONTENT=\"3; URL=tagboard.php\">"
        echo 
    "$beginning.Hello $nick.$ending"
        
    $ff_input "$nick%%$message@@" "##$REMOTE_ADDR\n" $output
        
    $s fopen($shouts"w"); 
        
    fwrite($sstripslashes($ff_input)); 
        
    fclose($s); 
    } else if (
    $REMOTE_ADDR == $modip) { 
        echo 
    "<META HTTP-EQUIV=\"REFRESH\" CONTENT=\"3; URL=tagboard.php\">"
        echo 
    "$beginning.Hello $mod.$ending"
        
    $ff_input "$nick%%$message@@" "##$REMOTE_ADDR\n" $output
        
    $s fopen($shouts"w"); 
        
    fwrite($sstripslashes($ff_input)); 
        
    fclose($s); 
    } else { 
        echo 
    "$beginning$imposter"
        if (
    $trackonvoid == on
        
    $ff_input "MSG/$message" "IP/$REMOTE_ADDR\n" $output
        
    $s fopen($mimp"w"); 
        
    fwrite($sstripslashes($ff_input)); 
        
    fclose($s);  

         
    /* END M&A PART */
        
    $output "";
    $file_lines file($shouts);

    foreach(
    $file_lines as $line) {
        
    $output .= $line;
    }

    if (
    $url != "" && $url != "http://") {
        
    $nick "<A href=\"$url\" target=\"_blank\">$nick</A>";
    }

    $ff_input "$nick%%$message@@" "##$REMOTE_ADDR\n" $output;
    $s fopen($shouts"w");
    fwrite($sstripslashes($ff_input));
    fclose($s);
        
    if (
    $emailnotify == on) {
        
    mail($emailaddy$emailsubject$emailbody "From: $emailsig");
    }

    echo 
    "    <META HTTP-EQUIV=\"REFRESH\" CONTENT=\"3; URL=tagboard.php\">\n";
    echo 
    "<center>";
    echo 
    "Redirecting...";
    echo 
    "$ending";
    echo 
    "</center>";

    echo 
    "  </BODY>\n";
    echo 
    "</HTML>";

    ?>
    My Website: DumpsterDoggy

  • #7
    THM
    THM is offline
    New Coder
    Join Date
    Jun 2006
    Location
    Philladelphia
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yes! Its working from what i can see so far. THANK YOU SO MUCH! I'll deffinatly leave you a line in the credits.


  •  

    Posting Permissions

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