title: How to update specific table row in mysql table using php
body: <p>I am beginner in php , i am trying to update specific row but does not work . i need your help: 
         <strong>update.php</strong>
        DIR . '/db_connect.php';
             // connecting to db
          $db = new DB_CONNECT();</p>
  
  <pre><code>    if (isset($_POST['id'])) {
  
  $id = $_POST["id"];
  $location = $_POST["location"];
    $sql=mysql_query("UPDATE citizenalert set location={'$location'} WHERE id ={'$id'}");
  }
  
    ?&gt; 
  </code></pre>
  
  <p><strong>db_config.php</strong></p>
  
  <pre><code>  &lt;?php
  
     define('DB_USER', "root"); // db user
     define('DB_PASSWORD', ""); // db password (mention your db password here)
       define('DB_DATABASE', "ikirenga"); // database name
        define('DB_SERVER', "localhost"); // db server
       ?&gt;
  </code></pre>
  
  <p><strong>db_connect.php</strong></p>
  
  <pre><code>           &lt;?php
  
    class DB_CONNECT {
  
  // constructor
  function __construct() {
      // connecting to database
      $this-&gt;connect();
  }
  
  // destructor
  function __destruct() {
      // closing db connection
      $this-&gt;close();
  }
  
  /**
   * Function to connect with database
   */
  function connect() {
      // import database connection variables
      require_once __DIR__ . '/db_config.php';
  
      // Connecting to mysql database
      $con = mysql_connect(DB_SERVER, DB_USER, DB_PASSWORD) or die(mysql_error());
  
  
      // Selecing database
      $db = mysql_select_db(DB_DATABASE) or die(mysql_error()) or die(mysql_error());
  
      // returing connection cursor
      return $con;
  }
  
  /**
   * Function to close db connection
   */
  function close() {
      // closing db connection
      mysql_close();
  }
      }
     ?&gt;
  </code></pre>
  
  <p><strong>request_update.php</strong></p>
  
  <pre><code>               &lt;!doctype html&gt;
  
                  &lt;html lang="en"&gt;
  
                     &lt;body&gt;
                    &lt;form name="updates" method="post" action="update.php" &gt; 
                     &lt;label&gt;User location&lt;/label&gt; &lt;input id="location"  type="text" name="location" &gt; &lt;br&gt;&lt;br&gt;
                       &lt;input type="submit" name="submit" value="Submit" /&gt; 
                       &lt;/form&gt;  
                       &lt;/body&gt;
                       &lt;/html&gt;
  </code></pre>