title: Php - MySQL select data from table, then update the same table
body: <p>What is wrong with this code ?</p>
  
  <pre><code>$sql=mysql_query("SELECT * FROM table WHERE id='$id'");
  if($data=mysql_fetch_array($sql))
      {
  $count=$data['count'];
  $new_count=$count+1;
  $sqla="UPDATE table SET count='$new_count' WHERE id='$id'";
  if(mysql_query($sqla))
  {
  echo "success";
  }
  </code></pre>
  
  <p>Everything is working fine except UPDATE query.</p>
  
  <p>when I add an </p>
  
  <pre><code>echo $new_count;
  </code></pre>
  
  <p>it returns the correct value.</p>