title: PHP and MySQL query based on user input not working
body: <p>I am creating a users database where there are 4 fields: ID, username, password, and occupation. This is a test database. I tried querying the db table and it worked but i have a lot of trouble having a user input and a MySQL query based off of it. I run an Apache server in Linux (Debian, Ubuntu).</p>
  
  <p>I have 2 pages. The first one is a bare-bone test index page. this is where there are textboxes for people to input easy info to register their info in the db. Here is the code for it:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;html&gt;
  &lt;form action="reg.php" method="POST"&gt;
    Username:
    &lt;input type="text" name="u"&gt;Password:
    &lt;input type="password" name="p"&gt;Occupation:
    &lt;input type="text" name="o"&gt;
    &lt;input type="submit" value="register"&gt;
  
  
  &lt;/form&gt;
  
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>After the submit button is clicked. It goes to the reg.php file. This is where it gets complicated. The page goes blank!!! Nothing is displayed or inputted in the db. Normal queries work well, but when user interaction is added, something is wrong. Here is the code for reg.php:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;?php
  $un = $_POST["u"]
  $pk = $_POST["p"]
  $ok = $_POST["o"]
  $u = mysql_real_escape_string($un);
  $p = mysql_real_escape_string($pk);  
  $o = mysql_real_escape_string($ok);    
  
  $link = mysql_connect('localhost', 'root', 'randompassword');
  if (!$link){
  die(' Oops. We Have A Problem Here: ' . mysql_error());
  }
  
  if ($link){
  echo 'connected succesfully';
  }
  
  mysql_select_db("forum") or die(' Oops. We Have A Problem Here: ' . mysql_error());
  $data = mysql_query("INSERT INTO users (username, password, occupation) VALUES ('{$u}', '{$p}', '{$o}')");
  
  ?&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>Can anyone hep me to correct this code to make this work?
  Thank you so much for your time. Much appreciated. </p>
  
  <p>EDIT:
  I noticed that i did not add semicolons in the first 3 lines. after doing so i got this error: "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 '{'', '', '')' at line 1." Can someone explain why?</p>
  
  <p>EDIT:  the website is just on my local machine...
  on an apache server on linux</p>