...

View Full Version : error



sytodave88
12-29-2005, 06:52 PM
Parse error: parse error, unexpected T_ELSE in /home/sytodave/public_html/crewforum/newtopic.php on line 92



Line 92


header("Location: read.php?id=$reply");
}
else {
}


the rest of programme


<?
ob_start();
include "includes/db_connect.php";
include_once "includes/functions.php";
logincheck();
$ok = 0;

$name = $_SESSION['username'];

$result = mysql_query("SELECT crew FROM users WHERE username = '$name'");
$row = mysql_fetch_array($result);
$usergang = $row[0];
if ($usergang == '0') {
echo "<link rel='stylesheet' href='inc/style.css'>You must be in a gang to view the gang forum!";
exit();

}

if($_POST["submit"]) {
require("conf.php");
$ok = 1;
if(empty($subject))
$err[] = "You've forgotten your subject!";



if(empty($bericht))
$err[] = "You've forgotten your message!";

for($i=0;$i<sizeof($bad_words);$i++)
if(ereg($bad_words[$i], $name) || ereg($bad_words[$i], $subject) || ereg($bad_words[$i], $bericht))
$err[] = "We like to keep our forum desent. Please use some normal language!";

if(sizeof($err) > 0) {
?>
<html>

<head>
<title></title>
<link rel="stylesheet" type="text/css" href="inc/style.css">
</head>

<body>
</table>
<table width="90%" border=0 cellspacing=0 cellpadding=0>
<tr><td class="MainTD">
<table width="100%" border=0 cellspacing=1 cellpadding=3>
<tr>
<td background="includes/grad.jpg">New Topic</td>
</tr>
<tr>
<td valign="top" align="left" class="NormalText">
<form method="POST" action="<?=$PHP_SELF?>">
<input type="hidden" name="subject" value="<?=$subject?>">
<input type="hidden" name="name" value="<?=$name?>">
<input type="hidden" name="bericht" value="<?=$bericht?>">
<input type="hidden" name="reply" value="<?=$reply?>">
Error,<br><br>
Something went wrong. Please take attention to the errors below.<br><br>
<?
for($i=0;$i<=sizeof($err);$i++)
echo "\n\t<font class=\"Error\">".$err[$i]."</font><br>";
?>
<input type="submit" STYLE="border:2px solid;color:#000000; background-color:#FF8C00" value="Back">
</form>
</td>
</tr>
</table>
</td></tr>
</table>
</body>
</html>
<?
} else {
require_once("inc/mysql_connect.php");
$sql = "INSERT INTO forum_gang_topics (topic_id, title, author, post, date, lastpost, gang) VALUES ('', '$subject', '$u', '$bericht', NOW(), NOW(), '$usergang')";
mysql_query($sql) or die("<h1>Something went wrong</h1><hr>".mysql_error());

if($reply <> 0) {
$sql = "UPDATE forum SET replys = replys + 1 WHERE id = '$reply'";
mysql_query($sql) or die("<h1>Something went wrong</h1><hr>".mysql_error());
}
}
}

if($reply == 0)
header("Location: index.php");

else{
header("Location: read.php?id=$reply");
}
else {
}

if(!isset($reply))
$reply = 0;
}

?>
<html>

<head>
<title>Forum</title>
<link rel="stylesheet" type="text/css" href="inc/style.css">
<script language="JavaScript">
<!--
function SubmitOnce(theform) {
// if IE 4+ or NS 6+
if (document.all || document.getElementById) {
// hunt down "submit" and "reset"
for (i=0;i<theform.length;i++) {
var tempobj=theform.elements[i];
if(tempobj.type.toLowerCase()=="submit"||tempobj.type.toLowerCase()=="reset") {
//disable it
tempobj.disabled=true;
}
}
}
}
//-->
</script>
</head>

<body>
</table>
<table width="90%" border=0 cellspacing=0 cellpadding=0>
<tr><td class="MainTD">
<table width="100%" border=0 cellspacing=1 cellpadding=3>
<tr>
<td background="includes/grad.jpg"><b>New Topic</b></td>
</tr>
<tr>
<td valign="top" align="left" class="NormalText">
<form name="postform" onsubmit="SubmitOnce(this);" method="POST" action="<?=$PHP_SELF?>">
Subject:&nbsp;
<input type"text" name="subject" style="background-image: url(images/form_bg.gif); font-family: Verdana; font-size: 10px; padding: 4px 4px 4px 4px; border: 1px solid black;" value="<?=$subject?>"><br>
<textarea name="bericht" rows="8" cols="40" style="background-image: url(images/form_bg.gif); background-repeat: repeat-x; font-family: Verdana; font-size: 10px; padding:4px; border: 1px solid black;"><?=$bericht?></textarea><br>
<input type="hidden" name="reply" value="<?=$reply?>">
<input type="hidden" name="submit" value="true">
<input type="submit" STYLE="border:2px solid;color:#000000; background-color:#FF8C00" value="Submit" >
</form>
<?
}
?>
</td>
</tr>
</table>
</td></tr>
</table>
</body>
</html>

TheShaner
12-29-2005, 07:40 PM
Well, the error is referring to the extra else. You can only have one else in an if statement. Corrected code below.

if($reply == 0)
header("Location: index.php");
else
header("Location: read.php?id=$reply");
However, after you fix this, you'll probably get more errors. You have too many closing brackets. Go over your entire code and match up the opening and closing brackets and decide which code is in which brackets.

Also, the below code:

for($i=0;$i<sizeof($bad_words);$i++)
if(ereg($bad_words[$i], $name) || ereg($bad_words[$i], $subject) || ereg($bad_words[$i], $bericht))
$err[] = "We like to keep our forum desent. Please use some normal language!";
Usually doesn't work in most programming languages. I have never tested this in PHP but just to be sure, i'd bracket it like so:

for($i=0;$i<sizeof($bad_words);$i++)
{
if(ereg($bad_words[$i], $name) || ereg($bad_words[$i], $subject) || ereg($bad_words[$i], $bericht))
$err[] = "We like to keep our forum desent. Please use some normal language!";
}
-Shane

missing-score
12-29-2005, 08:26 PM
actually it would work ok, and would actually work in alot of languages, but IMO, brackets are much easier to work with not to mention much more readable.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum