title: Undefined index Error and query not running?
body: <p>I am getting this error</p>
  
  <blockquote>
    <p>Notice: Undefined index: maxvalid in C:\wamp\www\myproj\includes\func.php on line 26</p>
  </blockquote>
  
  <p>and my code is</p>
  
  <pre><code>require("common.php");
  
  $incquery = "select max($TabFld) as maxvalid from $TabName";
  
      $stmt = $db-&gt;prepare($incquery);
      $incresult = $stmt-&gt;execute();
  
      $row=$stmt-&gt;fetchAll();
  
      $maxvalid = $row['maxvalid'];
  
      if($maxvalid &lt;&gt; NULL)
  
      {            
  
              $incvalid=$row['maxvalid']+1;
  
      }
  
  
      return $incvalid;
  </code></pre>
  
  <p>I am using PDO to connect mysql and I never used it before. I always use <code>mysql_connect</code> to connect database and I cannot understand why I am getting this error.</p>
  
  <p>I also debug the code and see that value is not coming in <code>$maxvalid</code> variable but it came when I use <code>mysql_connect</code>.</p>