title: using php to submit form data to MySQL database
body: <p>I am trying to create a form to submit data into a MySQL database but it is not working. At the moment I have the following error for my INSERT query:</p>
  
  <p>PHP Syntax Check: Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING) in your code </p>
  
  <p>at the moment I have the following php </p>
  
  <pre><code>&lt;?php 
  
   $mysqli = new mysqli("localhost", "root", "", "etrading");
  
   /* check connection */
   if ($mysqli-&gt;connect_errno) {
      printf("Connect failed: %s\n", $mysqli-&gt;connect_error);
       exit();
     }
  
   //Query
    $query = "INSERT INTO item (Name, Description, img_path, Quantity, Category, Location, Sale_Type, Price,  Duration, Payment) VALUES
   ($_POST['name'], $_POST['description'], $_POST['photo'], $_POST['quantity'], $_POST['category'], $_POST['location'], $_POST['Sale_Type'], $_POST['price'], $_POST['duration'], $_POST['payment'])";
  
      $result = mysql_query($query);
      if($result){
         echo("&lt;br&gt;Input data is succeed");
  } else{
      echo("&lt;br&gt;Input data is fail");
   }
  
    /* close connection */
    $mysqli-&gt;close();
  
   ?&gt;
  </code></pre>
  
  <p>This is currently what I have for my form. I am yet to still write code in for uploading an image. I am currently trying to get the form to work with no errors before I attempt the image upload.</p>
  
  <pre><code>&lt;form id="sellitem" action="sellitem.php" method="POST" onsubmit="return checkForm(this);" &gt;
          &lt;fieldset&gt;
              &lt;h4&gt;Sell Your Item&lt;/h4&gt;
              &lt;p&gt;&lt;label class="title" for="name"&gt;Name:&lt;/label&gt;
              &lt;input type="text" placeholder="Enter item name" name="name" id="name" title="Please enter item name" &gt;&lt;br /&gt;
  
              &lt;label class="title" for="text"&gt;Description:&lt;/label&gt;
              &lt;textarea name="description" rows="5" cols="33" type="text" placeholder="Please describe your item"  id="description" title="Please describe your item" &gt;&lt;/textarea&gt;&lt;br /&gt;
  
              &lt;label class="title" for="category"&gt;Category:&lt;/label&gt;
              &lt;select name="category" id="category" &gt;
                  &lt;option value="clothes"&gt;Clothes&lt;/option&gt;
                  &lt;option value="books"&gt;Books&lt;/option&gt;
                  &lt;option value="electronics"&gt;Electronics&lt;/option&gt;
                  &lt;option value="sport"&gt;Sport&lt;/option&gt;
              &lt;/select&gt;&lt;/p&gt;
  
              &lt;label class="title" for="location"&gt;Location:&lt;/label&gt;
              &lt;input type="text" placeholder="Item Location" name="location" id="location" title="Enter item location" &gt;&lt;br /&gt;
  
              &lt;label class="title" for="name"&gt;Sale Type:&lt;/label&gt;
              &lt;select name="Sale_Type" id="Sale_Type" &gt;
                  &lt;option value="Auction"&gt;Auction&lt;/option&gt;
                  &lt;option value="BuyNow"&gt;Buy Now&lt;/option&gt;
              &lt;/select&gt;
  
              &lt;label class="title" for="price"&gt;Price: $&lt;/label&gt;
              &lt;input type="text" placeholder="00.00" name="price" id="name" title="Please enter your name" &gt;&lt;br /&gt;
  
              &lt;label class="title" for="name"&gt;Quantity:&lt;/label&gt;
              &lt;input type="text" placeholder="Number of items" name="quantity" id="name" title="Number of items" &gt;&lt;br /&gt;
  
              &lt;label class="title" for="name"&gt;Duration:&lt;/label&gt;
              &lt;input type="text" placeholder="End date" name="duration" id="duration" title="End Date" &gt;&lt;br /&gt;
  
              &lt;label class="title" for="name"&gt;Payment Type:&lt;/label&gt;
              &lt;select name="payment" id="payment" &gt;
                  &lt;option value="PayPal"&gt;PayPal&lt;/option&gt;
                  &lt;option value="Bank Deposit"&gt;Bank Deposit&lt;/option&gt;
                   &lt;option value="Card"&gt;Credit Card&lt;/option&gt;
              &lt;/select&gt;&lt;br&gt;
              Select image to upload:
               &lt;input type="file" name="img_path" id="img_path" &gt;
  
  
              &lt;div class="submit"&gt;&lt;input type="submit" value="Submit" /&gt;&lt;/div&gt;
              &lt;div class="reset"&gt;&lt;input type="reset" value="Reset" /&gt;&lt;/div&gt;
  
              &lt;/fieldset&gt;
  
              &lt;/form&gt;
  </code></pre>
  
  <p>If I could please get some help as to why this error is appearing. Also a useful link/site to creating a simple upload photo to the MySQL database would also be helpful. </p>