title: Unable to insert data in mysql table via php
body: <p>I am unable to inset data into mysql table. What is wrong with my code?
  Here is the php code i have used. I am getting no response on submission.
  The php is used in the same page the html form is included so, my attributes are  action="" and method="post". Please help. 
  <code>enter code here</code></p>
  
  <pre><code>&lt;?php
      ob_start();
      session_start();
      require_once 'dbconnect.php';
  
      // if session is not set this will redirect to login page
      if( !isset($_SESSION['user']) ) {
          header("Location: index.html");
          exit;
      }
      // select loggedin users detail
      $res=mysql_query("SELECT * FROM users WHERE userId=".$_SESSION['user']);
      $userRow=mysql_fetch_array($res);
  
  
      if ( isset($_POST['sub']) ) {
  
          // clean user inputs to prevent sql injections
          $name1 = $_POST['name1'];
          $name2 = $_POST['name2'];
          $name3 = $_POST['name3'];
          $name4 = $_POST['name4'];
          $name5 = $_POST['name5'];
          $name6 = $_POST['name6'];
          $name7 = $_POST['name7'];
          $name8 = $_POST['name8'];
          $name9 = $_POST['name9'];
  
  
          if( !$error ) {
  
              $query = "INSERT INTO users(name1,name2,name3,name4,name5,name6,name7,name8,name9) VALUES('$name1','$name2','$name3','$name4','$name5','$name6','$name7','$name8','$name9') WHERE userId=".$_SESSION['user'];
              $res = mysql_query($query);
  
              if ($res) {
                  $errTyp = "success";
                  $errMSG = "Successfully registered, you may login now";
                  unset($name1);
  
              } else {
                  $errTyp = "danger";
                  $errMSG = "Something went wrong, try again later...";   
              }
              }
  }
  ?&gt;
  </code></pre>