title: how can i capture null values from mssql_result?
body: <p>I am running a query </p>
  
  <pre><code>$Health = mssql_query("Select 
  *
  from
  Health
  where 
  HEA_ID = '$HEA_ID'
  ");
  </code></pre>
  
  <p>and then capturing one of the fields here:</p>
  
  <pre><code>$HEA_DocsOnFile = mssql_result($Health,0,'HEA_DocsOnFile');
  </code></pre>
  
  <p>the field <code>HEA_DocsOnFile</code> is a <code>bit</code> in <code>sql server</code></p>
  
  <p><strong>how do i know whether <code>HEA_DocsOnFile</code> is a <code>NULL</code> or a <code>0</code>?</strong></p>
  
  <p>unfortunately <code>mssql_result</code> returns the same value for <code>NULL</code> and <code>0</code>!</p>
  
  <p>i've also tried:</p>
  
  <pre><code>$HEA_DocsOnFile = is_null(mssql_result($Health,0,'HEA_DocsOnFile')) ? null : mssql_result($Health,0,'HEA_DocsOnFile');
  </code></pre>
  
  <p>to make sure to set <code>$HEA_DocsOnFile</code> to <code>null</code></p>
  
  <p>and later to check a checkbox if it's 0 and NOT NULL this way:</p>
  
  <pre><code>&lt;?php if($HEA_DocsOnFile===0)  { echo  'checked="checked"' ; }?&gt;
  </code></pre>
  
  <p>even though it is indeed null (as sql server says at least), it still checks the checkbox thinking that it is <code>0</code></p>
  
  <p><strong>update</strong>
  per marc's suggestion, i explicitly selected all the columns instead of doing <code>select *</code></p>
  
  <p>i did:</p>
  
  <pre><code>select
  ....
   ,[HEA_POLST]
        ,[HEA_MOST]
        ,[HEA_DNR]
        ,isnull(HEA_DocsOnFile,2) HEA_DocsOnFile
  from...........
  </code></pre>
  
  <p>i know that <code>HEA_DocsOnFile</code> is now <code>2</code></p>
  
  <p>however, when testing:</p>
  
  <pre><code>&lt;?php if($HEA_DocsOnFile==1)  { echo  'checked="checked"' ; }?&gt;
  </code></pre>
  
  <p>it actually checks the box!</p>
  
  <p>what am i doing wrong?</p>
  
  <p>i actually did a <code>var_dump($HEA_DocsOnFile);</code> and it returned <code>int(1)</code></p>
  
  <p>how can that be? it is <strong>NULL</strong> in sql server!!</p>
  
  <p>i even did:</p>
  
  <pre><code>select............
      ,isnull(HEA_DocsOnFile,'2') HEA_DocsOnFile
  </code></pre>
  
  <p>to change the type from <code>int</code> to <code>string</code> and then did a <code>var_dump</code> and it <strong>STILL RETURNED</strong> <code>int(1)</code></p>