title: How to resolve Undefined index: Notice when displaying database retrieved value in php
body: <p>I'm getting an undefined index notice, but can't figure out how to fix it.</p>
  
  <p>Below is the code which is generating the error:</p>
  
  <pre><code>&lt;?php
  
  include 'dbconfig.php';
  
  $id;
  
  if(isset($_POST['Tid']))
  {
    $id=$_POST['To_ID'];
    echo "selected value:".$id;
    $query="select 'ID','Name' from  where ID='$id'";
    $result=sqlsrv_query($conn,$query);
    $a=sqlsrv_num_rows($result);
    echo $a;
  
    if(!$result)
    {
      echo "Query execution failed"; 
    }   
    else {
      while($row = sqlsrv_fetch_array($result))
      {
         print_r($row['ID'].$row['Name']);
      }
    } 
  } 
  else {
    echo "Post variable not set";
  }
  </code></pre>
  
  <p>I am getting error on the line here-</p>
  
  <pre><code>print_r($row['ID'].$row['Name']);
  </code></pre>
  
  <p>And also i am verified database columns the columns ID and Name is present in the database and the select query is also executing well when i tried seperately.</p>
  
  <p>Even though the filed name ID and Name exists i am getting Undefined Index ID and Name Error.</p>
  
  <p>Please help me to resolve this error.</p>
  
  <p>Thanks in advance.</p>