title: php mssql while loop
body: <p>I have an unusual issue with my while loop,</p>
  
  <p>here is the code:</p>
  
  <pre><code>$link = mssql_connect($myServer, $myUser, $myPass);
  
  if (!$link || !mssql_select_db($myDB, $link)) {
      die('Unable to connect or select database!');
  }
  
  $result = mssql_query("SELECT
  TBL_1.FULLNAME AS FullName,
  CAST(TBL_3.NOTE AS VARCHAR(MAX)) AS Note,
  TBL_3.CREATEDATE AS CreateDate,
  TBL_4.UNAME AS Creator
  FROM
  database.dbo.TBL_1 TBL_1,
  database.dbo.TBL_2 TBL_2,
  database.dbo.TBL_3 TBL_3,
  database.dbo.TBL_4 TBL_4
  WHERE
  TBL_1.UID = TBL_2.UID AND
  TBL_2.NOTEID = TBL_3.NOTEID AND
  TBL_3.CREATORID = TBL_4.USERID AND
  TBL_1.UID = '$id'
  ORDER BY CreateDate desc") or die(mssql_get_last_message());
  
  if (!mssql_num_rows($result)) {
                              echo '&lt;tr&gt;
                                      &lt;td width="600px"&gt; No results returned&lt;/td&gt;
                                      &lt;/tr&gt;';
                          } else {
                              while ($row =mssql_fetch_assoc($result)){                           
                              echo "&lt;tr&gt;
                                      &lt;td width='15px'&gt; ".++$counter." &lt;/td&gt;
                                      &lt;td width='600px'&gt; ".$row['Note']." &lt;/td&gt;
                                      &lt;td width='185px'&gt;".$row['CreateDate']."&lt;/td&gt;
                                      &lt;td width='185px'&gt;".$row['Creator']."&lt;/td&gt;
                                  &lt;/tr&gt;";
                                  }
                      }
  </code></pre>
  
  <p>For majority of the records, everything is as expected.  In some cases though,  the while loop doesn't respond at all.  no errors, no text, just as if I never ran the command.</p>
  
  <p>I tried searching and reading as much as I could, but without an error, its quiet difficult to find the solution.  </p>
  
  <p>Have tried using foreach instead, and it took a ton of scrubbing and cleaning to get it to not show 1 character per line.  Though it really just kept repeating the 1st record.  </p>
  
  <p>I should also point out that 1 of the rows is in RTF format, but I dont think that plays a role.  </p>
  
  <p>I'm connecting from a *nix machine to a MS SQL2005 server.  </p>
  
  <p>Thanks in advance for any and all advice!</p>