...

View Full Version : unexpected T_ELSE Error and Need help



THM
06-21-2006, 08:19 PM
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 :D



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($s, stripslashes($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($s, stripslashes($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($s, stripslashes($ff_input));
fclose($s);
}

PremiumBlend
06-21-2006, 08:34 PM
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:


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($s, stripslashes($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($s, stripslashes($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($s, stripslashes($ff_input));
fclose($s);
}

THM
06-21-2006, 08:46 PM
ok. now i added that, and i'm getting this...


Parse error: parse error, unexpected $ on line 184

?>

Thats all thats on line 184... So? Any ideas?

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

PremiumBlend
06-21-2006, 08:50 PM
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:


?>

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.

THM
06-21-2006, 08:53 PM
<?

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($nick, 0, 4) == "nick" || trim($nick) == "" )
{
echo "$beginning$error_nonick$ending";
exit;
}

if ( $message == "" || substr($message, 0, 7) == "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+1 <= $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($s, stripslashes($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($s, stripslashes($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($s, stripslashes($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($s, stripslashes($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...

PremiumBlend
06-21-2006, 09:53 PM
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.


<?

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($nick, 0, 4) == "nick" || trim($nick) == "" ) {
echo "$beginning$error_nonick$ending";
exit;
}

if ( $message == "" || substr($message, 0, 7) == "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+1 <= $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($s, stripslashes($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($s, stripslashes($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($s, stripslashes($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($s, stripslashes($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>";

?>

THM
06-21-2006, 10:07 PM
Yes! Its working from what i can see so far. THANK YOU SO MUCH! I'll deffinatly leave you a line in the credits.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum