title: Parse error: syntax error, unexpected 'insert'
body: <p>I am new to php. I am trying to connect android with phpmyadmin using webservice .</p>
  
  <p><strong>php Code</strong></p>
  
  <pre><code>&lt;?php
      include_once('configuration.php');
  
  
  $UserId = $_POST['UserId'];
  $ProductId = $_POST['ProductId'];
  $DesiredQuantity = $_POST['DesiredQuantity'];
  $cartstable=mysql_query("SELECT `UserId`, `ProductId`, `DesiredQuantity` FROM `carts` WHERE UId='".$UserId. "' AND ProductId='".$ProductId. "'");
  
      $num_rows = mysql_num_rows($cartstable);
          if($num_rows&gt;0){
   $updateqry=mysql_query("Update `carts` set `DesiredQuantity`= `DesiredQuantity` + $DesiredQuantity) WHERE UId='".$UserId. "' AND ProductId='".$ProductId. "');
  
  }
         else
  {
  $insertqry=mysql_query ("Insert into `carts` (`UId`, `ProductId`, `DesiredQuantity`) VALUES ('".$UserId. "','".$ProductId. "',$DesiredQuantity)");
  
  }
  
  
          $carts_ful=mysql_query("SELECT `UserId`, `ProductId`, `DesiredQuantity` FROM `CARTS` WHERE UId='".$UserId. "'");
  
         while($carts = mysql_fetch_array($carts_ful)){
          extract($carts);
          $result[] = array("UserId" =&gt; $UserId,"ProductId" =&gt; $ProductId,"DesiredQuantity" =&gt; $DesiredQuantity); 
      }
          $json = array("Updated Cart Details" =&gt; $result);
         @mysql_close($conn); 
          header('Content-type: application/json');
         // echo "Selected Product is added to the Cart !";
          echo json_encode($json);
  
  
   ?&gt;
  </code></pre>
  
  <p>When I tried running,I see the following error</p>
  
  <pre><code>&lt;b&gt;Parse error&lt;/b&gt;:  syntax error, unexpected 'insert' .
  </code></pre>
  
  <p>If I Cut and paste,</p>
  
  <pre><code> $insertqry=mysql_query ("Insert into `carts` (`UId`, `ProductId`, `DesiredQuantity`) VALUES ('".$UserId. "','".$ProductId. "',$DesiredQuantity)");
  </code></pre>
  
  <p>line above the if statement ,It works fine.</p>
  
  <p>I could not understand where is the problem .Please help me finding the solution .</p>