php - Check if INSERT succeeds -


here trying insert values in table course_student.the query running after inserting values in database not getting 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 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 - can echo "<script>alert('something')</script>"; lot clearer have, 2nd - echo $result; , check it's result.


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -