title: SQL syntax error while using MySQL and PHP
body: <p>I am trying to make a thing, but I have hit a problem. I have tried all I know, but I am new to <a href="http://en.wikipedia.org/wiki/MySQL" rel="nofollow">MySQL</a>, so I have hit a dead end.</p>
  
  <p>This code:</p>
  
  <pre><code>&lt;?php
      require('cfg.php');
      mysql_connect($server, $user, $pass) or die(mysql_error());
      mysql_select_db($database) or die(mysql_error());
  
      if (isset($_GET['name'])){
          $name = $_GET['name'];
      }
      else
          if (isset($_POST['submit'])){
              $name = $_POST['name'];
              $name1 = $_POST['name1'];
              $name2 = $_POST['name2'];
              $name3 = $_POST['name3'];
              mysql_query("INSERT INTO data (name, name1, name2, name3) VALUES($name, $name1, $name2, $name3 ) ") or die(mysql_error());
              echo ("Data entered successfully!");
          }
  ?&gt;
  
  &lt;html&gt;
      &lt;head&gt;
          &lt;title&gt;Random giffgaff simmer&lt;/title&gt;
      &lt;/head&gt;
      &lt;body&gt;
          &lt;form action="" method="post"&gt;
              &lt;p&gt;Your Username: &lt;input type="text" name="name"&gt;&lt;/p&gt;
              &lt;p&gt;Username 1: &lt;input type="text" name="name1"&gt;&lt;/p&gt;
              &lt;p&gt;Username 2: &lt;input type="text" name="name2"&gt;&lt;/p&gt;
              &lt;p&gt;Username 3: &lt;input type="text" name="name3"&gt;&lt;/p&gt;
              &lt;p&gt;Username 4: &lt;input type="text" name="name4"&gt;&lt;/p&gt;
              &lt;p&gt;Username 5: &lt;input type="text" name="name5"&gt;&lt;/p&gt;
              &lt;p&gt;Username 6: &lt;input type="text" name="name6"&gt;&lt;/p&gt;
              &lt;p&gt;&lt;input type="submit" name="submit" value="Submit"&gt;&lt;/p&gt;
          &lt;/form&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Brings this 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 ' )' at line 1</p>
  </blockquote>
  
  <p>Now, that would tell me that this SQL code has a syntax error:</p>
  
  <pre><code>INSERT INTO data (name, name1, name2, name3) VALUES($name, $name1, $name2, $name3 )
  </code></pre>
  
  <p>But I don't think I can see one?</p>