title: How to insert data into SQL Server database using php, jquery and ajax
body: <p>I'm new to SQL Server. I need to insert data into the database using php, jQuery, ajax and T-SQL. I'm using <code>sqlsrv</code> library, when I'm running this code in mysql it's working properly, but when I'm changing mysql to SQL Server, it's not working properly, and showing some array to string problem. How can I change mysql code to SQL Server and how to retrieve data using <code>sqlsrv</code>?</p>
  
  <p>Here is my code:</p>
  
  <pre><code>&lt;?php
       if(isset($_POST['first_name']) &amp;&amp; isset($_POST['last_name']) &amp;&amp; isset($_POST['email'])  &amp;&amp; isset($_POST['event1']))
      {
          // include Database connection file 
          include("db_connection.php");
  
          // get values 
          $first_name = $_POST['first_name'];
          $last_name = $_POST['last_name'];
          $email = $_POST['email'];
          $event1 = $_POST['event1'];
  
          $query = "INSERT INTO demo(first_name, last_name, email, event1) VALUES('$first_name', '$last_name', '$email', '$event1')";
          if (!$result = sqlsrv_query($conn, $query)) 
          {
              exit(sqlsrv_errors());
          }
          echo "1 Record Added!";
      }
  ?&gt;
  </code></pre>