title: Entering Email Addresses into MYSQL Database
body: <p>I am trying to insert emails into a MYSQL table, and I am getting an error:</p>
  
  <blockquote>
    <p>You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' 19, 'blah@gmail.com')' at line 1</p>
  </blockquote>
  
  <p>I've looked over the internet, and tried different combinations of collations and codes, but nothing will work. Is the '@' the problem here? I am getting this email address from decoding Facebook's JSON user object. Here are snippets from my code:</p>
  
  <pre><code>$user = json_decode(file_get_contents($jsonurl));
  $userid = $user-&gt;id;
  if($user-&gt;gender == "male") $usergender = TRUE;
  else $usergender = FALSE;
  $useremail = $user-&gt;email;
  
  mysql_select_db("kirkstat", $con);
  $result = mysql_query("INSERT INTO table (id, access, gender, age, email) VALUES ($userid, '$access_token', $usergender, 19, '$useremail')");
  if (!$result){
      echo("error.\n");
      die('Invalid query: ' . mysql_error());
  }
  </code></pre>
  
  <p>id is a bigint, access is a varchar, gender is a binary, age is an int, and email is a varchar.</p>
  
  <p>Thanks for your help!</p>