title: Ajax Post 500 server error
body: <p>I am trying to write some data to a MySQL Table however the .post call is returning with a 500 server error. Any help in the right direction would be great.</p>
  
  <p>I think it's something to do with the _POST variables not sending right.</p>
  
  <p>Here is the code:</p>
  
  <p>JS:</p>
  
  <pre><code>function write_table(response) {
    var data = {
      'user_id' : response.id,
      'user_email' : response.email,
      'user_first' : response.first_name,
      'user_last' : response.last_name
    };
  
    console.log(data);
  
    $.ajax({
      'url': './includes/php/login_facebook.php',
      'data': data,
      'type': 'POST',
      'beforeSend': function(xhr, settings) {
        console.log('ABOUT TO SEND');
      },
      'success': function(result, status_code, xhr) {
        console.log('SUCCESS!');
      },
      'complete': function(xhr, text_status) {
        console.log('Done.');
      },
      'error': function(xhr, text_status, error_thrown) {
        console.log('ERROR!', text_status, error_thrown);
      }
    });
  }
  </code></pre>
  
  <p>PHP:</p>
  
  <pre><code>    &lt;?php
  
  ini_set('display_errors',1);
  error_reporting(E_ALL);
  
  $host = 'localhost';
  $un = 'root';
  $pw = 'root';
  $db = 'bikelouis';
  
  $user_id = $_POST['user_id'];
  $user_email = $_POST['user_email'];
  $user_first = $_POST['user_first'];
  $user_last = $_POST['user_last'];
  
  $conn = mysql_connect($host, $un, $pw) or die(mysql_error());
  
  if ($conn) {
      echo '&lt;script&gt; alert("connected!");&lt;/script&gt;';
      mysql_select_db($db) or die(mysql_error());
      $sql = "INSERT INTO users (user_id, user_email, user_first, user_last) VALUES ($user_id, $user_email, $user_first, $user_last)";
  
  } else {
      echo 'Connection failed.';
  }
  ?&gt;
  </code></pre>
  
  <p>I am using facebook connect, that is where 'response' is coming from. That works perfectly.</p>