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 3 of 3

Thread: error

  1. #1
    New Coder
    Join Date
    Jul 2005
    Posts
    63
    Thanks
    0
    Thanked 0 Times in 0 Posts

    error

    Parse error: parse error, unexpected T_ELSE in /home/sytodave/public_html/crewforum/newtopic.php on line 92



    Line 92

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

    the rest of programme

    PHP Code:
    <?
    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>

  • #2
    Senior Coder TheShaner's Avatar
    Join Date
    Sep 2005
    Location
    Orlando, FL
    Posts
    1,126
    Thanks
    2
    Thanked 40 Times in 40 Posts
    Well, the error is referring to the extra else. You can only have one else in an if statement. Corrected code below.
    PHP Code:
    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:
    PHP 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:
    PHP 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!";

    -Shane

  • #3
    Senior Coder missing-score's Avatar
    Join Date
    Jan 2003
    Location
    UK
    Posts
    2,194
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.


  •  

    Posting Permissions

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