How to create a php forum sub category

Hey guys!

I am not sure why but it doesn’t seem to be inserting into my sub category database and I don’t get any error messages:


<?php
include_once 'header.php';
include_once 'includes/dbh.php';

?>

<!DOCTYPE html>
<html>
<head>
	<title>PianoCourse101 Forum</title>
	<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<center>
   <div id="holder">

      <div id="userInfo">
      <?php
         if($_SESSION['u_uid']) {
         	$sql = "SELECT * FROM users WHERE user_uid = ?;";

         	$stmt = mysqli_stmt_init($conn);
        if(!mysqli_stmt_prepare($stmt, $sql)) {
           echo "SQL error";
        } else {
          mysqli_stmt_bind_param($stmt, "s", $_SESSION['u_uid']);
          mysqli_stmt_execute($stmt);
          $result = mysqli_stmt_get_result($stmt);
          $resultCheck = mysqli_num_rows($result);
          
          
         }


     }

     if ($resultCheck == 0) {
          	 session_destroy();
          	 echo "Please <a href=\"./includes/login.php\">Login</a> to your account, or <a href=\"./signup.php\">Register</a> a new account \n";
          } else {
          	$row = mysqli_fetch_assoc($result);
          	echo "Welcome back,  <a href=\"./forum_main.php?act=profile&id=".$row['user_uid']."\">".$row['user_uid']."</a>!\n";
          	echo "<br>\n";

          	if($row['admin'] != 1) {

          	} else {
          		echo "<a href=\"./administrator.php\">Administrative section</a>\n";
          	}
          }
     
      ?>

      </div>

  
</center>
<div id="content">


 <?php  




if(!$_SESSION['u_uid']) {
	header("Location: index.php?admin=nopermission");
	exit();
} else {
	$sql = "SELECT admin FROM users WHERE user_uid = ?;";

	$stmt = mysqli_stmt_init($conn);
        if(!mysqli_stmt_prepare($stmt, $sql)) {
           echo "SQL error";
        } else {
          mysqli_stmt_bind_param($stmt, "s", $_SESSION['u_uid']);
          mysqli_stmt_execute($stmt);
          $result = mysqli_stmt_get_result($stmt);
          $resultCheck = mysqli_num_rows($result);
          
          if($resultCheck == 0) {
          	echo 'You are not correctly logged in!\n';
          } else {
          	$row = mysqli_fetch_assoc($result);
          	if ($row['admin'] != 1) {
          		echo '<h2>You are not permitted to be here!</h2>\n';
          	} else {
          		$act = $_GET['act'];
          		$acts = array('create_cat', 'create_subcat');
          		$actions = array('create_cat' => 'Create Forum Category', 'create_subcat' => 'Create Forum Sub Category');
                
                $x=1;
                $c = count($actions);
          		foreach($actions AS $url => $link) {
                   $bull = ($x == $c) ? "": " &bull; ";

                   echo "<a href=\"./administrator.php?act=".$url."\">".$link."</a>".$bull."\n";

                   $x++;
          		}

          		echo "<br><br>\n";

          		if(!$act || !in_array($act, $acts)) {
          			echo "Please choose an option from above to continue!\n";
          		} else {
          			if ($act == 'create_cat') {
          				if (!$_POST['submit']) {
          					echo "<table border=\"0\" cellspacing=\"3\" cellpadding=\"3\">\n";
          					echo "<form method=\"POST\" action=\"./administrator.php?act=create_cat\">\n";
          					echo "<tr><td>Category Name</td><td><input type=\"text\" name=\"name\"></td></tr>";
          					echo "<tr><td>Admin Only?</td><td><input type=\"checkbox\" name=\"admin\" value=\"1\"></td></tr>";
          					echo "<tr><td colspan=\"2\" align=\"right\"><input type=\"submit\" name=\"submit\" value=\"Create Forum Category\"></td></tr>";
          					echo "</form></table>\n";
          				} else {
          					$name = $_POST['name'];
          					$admin = $_POST['admin'];

          					if($name) {
          						if(strlen($name) < 3 || strlen($name) > 32) {
                                    echo "The category name must be between 3 and 32 characters!\n";
                                } else {
                                	$sql2 = "SELECT * FROM forum_cats WHERE name = ?;";

                                	$stmt = mysqli_stmt_init($conn);
							        if(!mysqli_stmt_prepare($stmt, $sql2)) {
							           echo "SQL error";
							        } else {
							          mysqli_stmt_bind_param($stmt, "s", $name);
							          mysqli_stmt_execute($stmt);
							          $result2 = mysqli_stmt_get_result($stmt);
							          $resultCheck2 = mysqli_num_rows($result2);
							          if ($resultCheck2 > 0) {
							          	  echo "The category name already exists!\n";
							          } else {
							          	   $admin_check = ($admin == 1) ? 1 : 0;
							          	   $sql3 = "INSERT INTO forum_cats (name, admin) VALUES (?,?);";

							          	   $stmt = mysqli_stmt_init($conn);
									        if(!mysqli_stmt_prepare($stmt, $sql3)) {
									           echo "SQL error";
									        } else {
									          mysqli_stmt_bind_param($stmt, "si", $name, $admin_check);
									          mysqli_stmt_execute($stmt);

									          }

									          echo "The forum category <b>".$name."</b> has been successfully added!";
                                }  
          					}
          				}
          			} else {
          						echo "You must supply a category name";
          					}
          		}   

          		

          			} if ($act == 'create_subcat') {
          			if(!$_POST['submit']) {
          				echo "<table border=\"0\" cellspacing=\"3\" cellpadding=\"3\">\n";
          				echo "<form method=\"POST\" action=\"./administrator.php?act=create_subcat\">\n";
          				echo "<tr><td>Forum Category</td><td><select name=\"cat\"><option value=\"0\">Please Choose....</option>\n";

          				$sql4 = "SELECT * FROM forum_cats ORDER BY id ASC;";

          				 $stmt = mysqli_stmt_init($conn);
									        if(!mysqli_stmt_prepare($stmt, $sql4)) {
									           echo "SQL error";
									        } else {
									         mysqli_stmt_execute($stmt);
									         $result3 = mysqli_stmt_get_result($stmt);
									         $resultCheck3 = mysqli_num_rows($result3);

									         if ($resultCheck3 < 1) {
									         	echo "</select><br>No categories exist\n";
									         } else {
									         	while ($row2 = mysqli_fetch_assoc($result3)) {
									         		echo "<option value=\"".$row2['id']."\">".$row2['name']."</option>\n";

									         	}
									         }
									         echo "</select></td></tr>\n";
									         echo "<tr><td>Sub Cat. Name</td><td><input type=\"text\" name=\"name\"></td></tr>\n";
									         echo "<tr><td>Description</td><td><textarea name=\"des\" style=\"width:300px height:60px\"></textarea></td></tr>\n";
									         echo "<tr><td colspan=\"2\" align=\"right\"><input type=\"submit\" value=\"Add Forum Sub Category\"></td></tr>";
									         echo "</form></table>\n";
                                           }
          		                           
										   } else {
          		                           	    $cat = $_POST['cat'];
          		                           	    $name = $_POST['name'];
          		                           	    $des = $_POST['des'];

          		                           	    if($cat && $name && $des) {
          		                           	    	$sql5 = "SELECT * FROM forum_cats WHERE id = ?;";

          		                           	    	$stmt = mysqli_stmt_init($conn);
											        if(!mysqli_stmt_prepare($stmt, $sql5)) {
											           echo "SQL error";
											        } else {
											         mysqli_stmt_bind_param($stmt, "i", $cat);	
											         mysqli_stmt_execute($stmt);
											         $result4 = mysqli_stmt_get_result($stmt);
											         $resultCheck4 = mysqli_num_rows($result4);

											         if ($resultCheck4 < 1) {
											         	 echo "The forum category you supplied does not exist\n";
											         } else {
											         	   $sql6 = "SELECT * FROM forum_sub_cats WHERE name = ? AND cid = ?;";
                                                           
                                                           $stmt = mysqli_stmt_init($conn);
													        if(!mysqli_stmt_prepare($stmt, $sql6)) {
													           echo "SQL error";
													        } else {
													         mysqli_stmt_bind_param($stmt, "si", $name, $cat);	
													         mysqli_stmt_execute($stmt);
													         $result5 = mysqli_stmt_get_result($stmt);
													         $resultCheck5 = mysqli_num_rows($result5);

													         if ($resultCheck5 > 0) {
													         	 echo "The forum sub category already exists within the main category\n";

													         } else {



                                                                   if (strlen($des) > 255) {
													         	 	echo "The description must be under 255 characters!\n";
													         	 } else {
                                                                    while ($row2 = mysqli_fetch_assoc($result3)) {
													         	 	$sql7 = "INSERT INTO forum_sub_cats (cid, name, des, admin) VALUES (?,?,?,?);";
                                                                    
                                                                    $stmt = mysqli_stmt_init($conn);
															        if(!mysqli_stmt_prepare($stmt, $sql7)) {
															           echo "SQL error";
															        } else {
															         mysqli_stmt_bind_param($stmt, "issi", $cat, $name, $des, $row2['admin']);	
															         mysqli_stmt_execute($stmt);

													         	 }	

													         	    echo "The forum sub category, <b>".$name."</b> has been added under the main category of <b>".$row2['name']."\n";

													         	}
		          		                       }
		          		                           }  
  
          			                   } 
          } 
      } 
}
}
}
}
}
}
}
}

?>

Try instead:

if(!mysqli_stmt_prepare($stmt, $sql7) or die(mysqli_error($conn))) {