Jump to content

PHP Parse Error (Solved)


Arceus
 Share

Recommended Posts

<?phprequire("include.php"); mysql_connect(localhost,$dbuser,$dbpassword);@mysql_select_db($database) or die();$tid=$_REQUEST['tid'];if (isset($_POST['message'])){$message=$_POST['message'];}$q1="SELECT * FROM Threads WHERE TID = '$tid'";mysql_query($q1);$r1=mysql_query($q1);$fid=mysql_result($q1,0,"FID");$title=mysql_result($q1,0,"title");$deleted=mysql_result($q1,0,"deleted");$threadurl=mysql_result($q1,0,"threadurl");$locked=mysql_result($q1,0,"locked");$unapproved=mysql_result($q1,0,"unapproved");$author=mysql_result($q1,0,"author");?><title><?php echo $title; ?></title></head><body>$query="SELECT * FROM Posts WHERE TID = '$tid'";mysql_query($query);$result=$mysql_query($query);$i=0;$num=mysql_numrows($result);$unapproved=mysql_result($result,0,"unapproved");if (isset($_POST['moderator'])){$tools=$_POST['tools'];$movethread=$_POST['movethread'];$moderator=_$POST['moderator'];if ($tools=="approve thread"){$q="UPDATE Threads SET unapproved = '0' WHERE TID = '$tid'";}else if ($tools=="unapprove thread"){$q="UPDATE Threads SET unapproved = '1' WHERE TID = '$tid'";}else if ($tools=="soft delete"){$q="UPDATE Threads SET deleted = '1' WHERE TID = '$tid'";}else if ($tools=="undelete"){$q="UPDATE Threads SET deleted = '0' WHERE TID = '$tid'";}else if ($tools=="destroy thread"){if (isset($_POST['confirm'])){$confirm=$_POST['confirm'];if ($confirm==0){echo "Action cancelled.<br />";}else{echo "Thread deleted.<br />";$q="DELETE FROM Threads WHERE TID = '$tid'";}} // Get rid of confirmationelse{ echo "Are you sure you wish to permanently delete this thread?";echo "<br />";?><form action="<?php echo $threadurl; ?>" method="post"><select name="confirm"><option value="0">No</option><option value="1">Yes</option></select><input type="hidden" name="tools" value="destroy thread" /><input type="hidden" name="moderator" value="<?php echo $username; ?>" /><input type="submit" value="Confirm" /></form><?php} // The problem line}   else if ($tools=="moderate thread") {$q="UPDATE Threads SET moderated = '1'";}else if ($tools=="unmoderate thread"){$q="UPDATE Threads SET moderated = '0' ";}else if ($tools=="lock thread"){$q="UPDATE Threads SET locked = '1'";}else if ($tools=="unlock thread"){$q="UPDATE Threads SET locked = '0'";}if ($movethread!=0){$q3="UPDATE Threads SET FID = '$movethread'";}mysql_query($q);if ($movethread!=0) // Only run if thread is being moved{mysql_query($q3);}} // End the thread moderator optionsif ($unapproved==0 || $unapproved==1 && $mod==1 || $admin==1 || $leader==1) /* Only show approved threads otherwise give error message. */{if ($unapproved==1 && $mod==1 || $admin==1 || $leader==1){echo "This thread was unapproved by " . $moderator . " for the following reason: " . $reason ."<br />";while($i<$num){$pid=mysql_result($result,$i,"PID");$poster=mysql_result($result,$i,"poster");$message=mysql_result($result,$i,"message");$moderated=mysql_result($result,$i,"moderated");if ($moderated==0 || $moderated==1 && $mod==1 || $admin==1 || $leader==1) /* Only show approved posts to regular members. Show all posts to staff.*/{if ($deleted==1 && $mod!=1 && $admin!=1 && $leader!=1){echo "The thread doesn't exist.<br />";}else if ($deleted==0 || $deleted==1 && $mod==1 || $admin==1 || $leader==1){ // Don't show to nonstaffecho $poster . "</t>" . $pid . "<br />";<img src="<?php echo $avatar; ?>" alt="<?php echo $poster; ?>'s avatar" /><br /><?php echo $message . "<br /><br />";} // Close Deleted=0} // Close Moderated$i++;} // Close While Loop} // Close Reason for unapproval} // Close view threadif ($unapproved==1 && $mod!=1 || $admin!=1 || $leader!=1){echo "The specified thread doesn't exist.<br />";}if ($mod==1 || $admin==1 || $leader==1){echo "Thread Tools: "; ?><form action="<?php echo $threadurl; ?>" method="post"><select name="tools"><?phpif ($threadmoderated==1) /* Thread needs to be approved */{ ?><option value="approve thread">Approve Thread</option><?php}else{ ?><option value="unapprove thread">Unapprove Thread</option><?php}if ($threaddeleted==0){ ?><option value="soft delete">Soft Delete Thread</option><?php}else{?><option value="undelete">Undelete Thread</option><?php}if ($admin==1 || $leader==1) /* Only let admins completely remove threads.*/{?><option value="destroy thread">Permanently Delete Thread</option><?php}if ($moderated==0) /*Force replies to be staff approved */{ ?><option value="moderate thread">Moderate Thread</option><?php}else{ ?><option value="unmoderate thread">Unmoderate Thread</option><?php}if ($locked==0){ ?><option value="lock thread">Lock Thread</option><?php}else{ ?><option value="unlock thread">Unlock Thread</option><?php}?></select>Move Thread: <select name="movethread"><option value="0">--</option><?php$q2="SELECT * FROM Forums";mysql_query($q2);$r2=mysql_query($q2);$x=0;$n=mysql_numrows($r2);while ($x<$n){$forum=mysql_result($r2,$x,"Forum");$fid=mysql_result($r2,$x,"FID");?><option value="<?php echo $fid; ?>"><?php echo $forum; ?></option><?php$x++;}?> </select>Reason: <input type="text" name="reason"><input type="hidden" name="moderator" value="<?php echo $username; ?>" /><input type="submit" value="Proceed" /></form></t><?php} // Closes the mod tools<br />?><form action="<?php echo $threadurl; ?>" method="post"><textarea rows="10" cols="70" name="message"></textarea><input type="submit" value="Quick Reply" /></form></body></html>

It says: Parse error: syntax error, unexpected '}' in /home/teamdime/public_html/members/thread.php on line 76I put a comment that says the problem line where line 76 is for reference. Any help would be appreciated.

Edited by Arceus
Link to comment
Share on other sites

wow. You should really try indenting your code and formatting it so it easier to read. By indenting all your control structures, you might find you have unnecessary bits of code.

Edited by thescientist
Link to comment
Share on other sites

Open a <?php tag at line 21.Doesn't your editor highlight syntax? I pasted your code into mine and the problem became immediately obvious when half your code showed up as plain text.You have other problems as well. Like passing $q1 to mysql_result when I think you mean $r1. There is also a variable called _$POST in there somewhere.

Link to comment
Share on other sites

Forgetting to start the PHP again was the main problem I couldn't seem to find. After that there were a couple minor errors which I was able to spot and fix. Thanks for the help.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...