php mssql while loop


php mssql while loop

我的while循环有一个不寻常的问题,

这是代码:

$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 '<tr>
                                    <td width="600px"> No results returned</td>
                                    </tr>';
                        } else {
                            while ($row =mssql_fetch_assoc($result)){                           
                            echo "<tr>
                                    <td width='15px'> ".++$counter." </td>
                                    <td width='600px'> ".$row['Note']." </td>
                                    <td width='185px'>".$row['CreateDate']."</td>
                                    <td width='185px'>".$row['Creator']."</td>
                                </tr>";
                                }
                    }

对于大多数记录,一切都符合预期。 但在某些情况下,while 循环根本不响应。 没有错误,没有文本,就好像我从未运行过命令一样。

我尝试尽可能多地搜索和阅读,但没有错误,很难找到解决方案。

尝试使用 foreach 代替,并且需要大量的擦洗和清洁才能使其每行不显示 1 个字符。 虽然它真的只是一直在重复第1条记录。

我还应该指出,其中 1 行是 RTF 格式,但我认为这不起作用。

我正在从 *nix 机器连接到 MS SQL2005 服务器。

提前感谢任何和所有的建议!

如果您

使用 freeTDS 作为驱动程序,那么在 smalldate 字段上一段时间它会产生一些问题,您可以做一件事来确保去找你 php.ini 并尝试切换

mssql.datetimeconvert = On

并在您的freetds.conf文件中尝试设置

client charset = UTF-8
text size = 1048576

这可能是一个问题,因为您没有任何线索,我面临这个问题并想与您分享。