Zoofu Posted August 23, 2009 Share Posted August 23, 2009 <?php $id = mss($_GET['id']); if($id){ $sql = "SELECT * FROM `forum_subcats` WHERE `id`='".$id."'"; $res = mysql_query($sql) or die(mysql_error()); if(mysql_num_rows($res) == 0){ echo "Invalid Path!\n"; }else { $row1 = mysql_fetch_assoc($res); if($row1['admin'] == 1 && $admin_user_level == 0){ echo "You do not have permission!\n"; }else { if(!$_POST['submit']){ echo "<center><table border=\"0\" cellspacing=\"3\" cellpadding=\"3\" width=\"100%\">\n"; echo "<form method=\"post\" action=\"./index.php?act=create&id=".$id."\">\n"; echo "<tr><td>Post in:</td><td><select name=\"cat\"></center>\n"; $sql2 = "SELECT * FROM `forum_cats` WHERE `admin` < ".$admin_user_level."+1"; $res2 = mysql_query($sql2) or die(mysql_error()); while($row = mysql_fetch_assoc($res2)){ $sql3 = "SELECT * FROM `forum_subcats` WHERE `cid`='".$row['id']."'"; $res3 = mysql_query($sql3) or die(mysql_error()); echo "<option value=\"0\">".$row['name']."</option>\n"; while($row2 = mysql_fetch_assoc($res3)){ $selected = ($row2['id'] == $id) ? " SELECTED" : ""; echo "<option value=\"".$row2['id']."\"".$selected.">     ".$row2['name']."</option>\n"; } } echo "</select></td></tr>\n"; echo "<center><tr><td>Title</td><td><input type=\"text\" name=\"title\"></td></tr>\n"; echo "<tr><td>Message</td><td><textarea name=\"message\" style=\"width:300px;height:100px;\"></textarea></td></tr>\n"; echo "<tr><td colspan=\"2\" align=\"center\"><input type=\"submit\" name=\"submit\" value=\"Create Topic\"></td></tr>\n"; echo "</form></table></center>\n"; }else { $cat = mss($_POST['cat']); $title = mss($_POST['title']); $msg = mss($_POST['message']); if($cat && $title && $msg){ $sql = "SELECT admin FROM `forum_subcats` WHERE `id`='".$cat."'"; $res = mysql_query($sql) or die(mysql_error()); if(mysql_num_rows($res) == 0){ echo "Invalid path!\n"; }else { $row = mysql_fetch_assoc($res); if($row['admin'] == 1 && $admin_user_level != 1){ echo "You do not have permission!\n"; }else { if(strlen($title) < 3 || strlen > 32){ echo "Title must range from 3-32 characters!\n"; }else { if(strlen($msg) < 3 || strlen > 10000){ echo "Message must range from 3-10000 characters!\n"; }else { $date = date("m-D-y") . " at " . date("h:i:s"); $time = time(); $sql2 = "INSERT INTO `forum_topics` (`cid`,`title`,`uid`,`date`,`time`,`message`) VALUES('".$cat."','".$title."','".$_SESSION['uid']."','".$date."','".$time."','".$msg."')"; $res2 = mysql_query($sql2) or die(mysql_error()); $tid = mysql_insert_id(); topic_go($tid); $sel=mysql_query("SELECT * FROM `users` WHERE `id`=".$_SESSION['uid']."") OR die(mysql_error()); $rowt=mysql_fetch_array($sel); $rowt['tokens']+=6; mysql_query("UPDATE `users` SET tokens='{$rowt['tokens']}' WHERE `id`=".$_SESSION['uid']."") OR die(mysql_error()); // will work. } } } } }else { echo "Please fill in all fields!\n"; } } } } }else { if(!$_POST['submit']){ echo "<table border=\"0\" cellspacing=\"3\" cellpadding=\"3\">\n"; echo "<form method=\"post\" action=\"./index.php?act=create\">\n"; echo "<tr><td>Post in:</td><td><select name=\"cat\">\n"; $sql2 = "SELECT * FROM `forum_cats` WHERE `admin` < ".$admin_user_level."+1"; $res2 = mysql_query($sql2) or die(mysql_error()); while($row = mysql_fetch_assoc($res2)){ $sql3 = "SELECT * FROM `forum_subcats` WHERE `cid`='".$row['id']."'"; $res3 = mysql_query($sql3) or die(mysql_error()); echo "<option value=\"0\">".$row['name']."</option>\n"; while($row2 = mysql_fetch_assoc($res3)){ $selected = ($row2['id'] == $id) ? " SELECTED" : ""; echo "<option value=\"".$row2['id']."\"".$selected.">     ".$row2['name']."</option>\n"; } } echo "</select></td></tr>\n"; echo "<tr><td>Title</td><td><input type=\"text\" name=\"title\"></td></tr>\n"; echo "<tr><td>Message</td><td><textarea name=\"message\" style=\"width:300px;height:100px;\"></textarea></td></tr>\n"; echo "<tr><td colspan=\"2\" align=\"right\"><input type=\"submit\" name=\"submit\" value=\"Create Topic\"></td></tr>\n"; echo "</form></table>\n"; }else { $cat = mss($_POST['cat']); $title = mss($_POST['title']); $msg = mss($_POST['message']); if($cat && $title && $msg){ $sql = "SELECT admin FROM `forum_subcats` WHERE `id`='".$cat."'"; $res = mysql_query($sql) or die(mysql_error()); if(mysql_num_rows($res) == 0){ echo "Invalid path!\n"; }else { $row = mysql_fetch_assoc($res); if($row['admin'] == 1 && $admin_user_level != 1){ echo "You do not have permission!\n"; }else { if(strlen($title) < 3 || strlen > 32){ echo "Title must range from 3-32 characters!\n"; }else { if(strlen($msg) < 3 || strlen > 10000){ echo "Message must range from 3-10000 characters!\n"; }else { $date = date("m-D-y") . " at " . date("h:i:s"); $time = time(); $sql2 = "INSERT INTO `forum_topics` (`cid`,`title`,`uid`,`date`,`time`,`message`) VALUES('".$cat."','".$title."','".$_SESSION['uid']."','".$date."','".$time."','".$msg."')"; $res2 = mysql_query($sql2) or die(mysql_error()); $tid = mysql_insert_id(); header("Location: index.php?act=topic&id=".$tid.""); $sel2=mysql_query("SELECT * FROM `users` WHERE `id`=".$_SESSION['uid']."") OR die(mysql_error()); $rowt2=mysql_fetch_array($sel2); $rowt2['tokens']+=6; mysql_query("UPDATE `users` SET tokens='{$rowt2['tokens']}' WHERE `id`=".$_SESSION['uid']."") OR die(mysql_error()); // won't work. } } } } }else { echo "Please fill in all fields!\n"; } } } ?> This doesn't make sense. How come on line 129 - 134 doesn't work. It won't add 6 tokens. >_> But it works further up... I've marked both now. Quote Link to comment Share on other sites More sharing options...
oni-kun Posted August 23, 2009 Share Posted August 23, 2009 Does it give you an error? Echo tokens variable before and after your changing code, I can't seem to parse your 1000 lines to see what it does, debugging is a must! Quote Link to comment Share on other sites More sharing options...
Zoofu Posted August 23, 2009 Author Share Posted August 23, 2009 No error. It adds 6 tokens when the 1st process goes through, but not the 2nd. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.