检查INSERT是否成功

Here I am trying to insert the values in the table course_student.The query is running successfully but after inserting values in the database I am not getting any alert.

<?php
if(isset($_POST['submit']))
{
$connect =new mysqli("localhost","root","","new");
if(!$connect)
{
    die("Database connection Error".mysql_error());
}

//select database

if(mysqli_connect_errno())
{
    die("Database selection Error".mysqli_connect_error());
}
$course=$_POST['select1'];
$userid=$_SESSION['user_id'];

$sql="INSERT INTO course_student (Courseid,Studentid)VALUES ($_POST[select1],'$userid')";
$result=$connect->query($sql);  
if ($result)
{  ?>
<html>
<body>
<script>
alert("fail");
</script>
</body>
</html>

<?php
}
else
{
?>
<script>
alert("fail");
</script>
<?php
}
}
?>

1st - you can do echo "<script>alert('something')</script>"; it a lot clearer than what you have, 2nd - echo $result; and check it's result.

  $sql="INSERT INTO course_student (Courseid,Studentid)VALUES ('".$_POST[select1]."','$userid')";
  $check = mysql_query($sql);
  if($check)
  {
  //If succeed
  }