PHP页面使用ODBC,数据源和MSSQL中途停止加载

时间:2022-09-07 04:36:07

We have a page that is mostly static with a few PHP includes, each of which pull data from our MSSQL database.

我们有一个主要是静态的页面,包含一些PHP包含,每个页面都从我们的MSSQL数据库中提取数据。

There is a very strange issue where pages will randomly stop rendering. The problem is sporadic and not always visible. Sometimes the pages load correctly, sometimes they stop before reaching the end of the file.

有一个非常奇怪的问题,页面会随机停止渲染。问题是零星的,并不总是可见的。有时页面加载正确,有时它们会在到达文件末尾之前停止。

The page in question where you can see the problem is at Dev: http://author.www.purdue.edu/discoverypark/climate/ Prod: http://www.purdue.edu/discoverypark/climate/index.php

您可以在Dev上看到问题的页面:http://author.www.purdue.edu/discoverypark/climate/产品:http://www.purdue.edu/discoverypark/climate/index.php

If you refresh the page repeatedly you will hopefully be able to see the issue. The problem only exists on pages that include calls to our database, but again the pages load completely normally most of the time; only sometimes it will stop outputting the page. It has broken inside of normal html as well as before and inside php blocks.

如果您反复刷新页面,您将希望能够看到该问题。该问题仅存在于包含对我们数据库的调用的页面上,但是大多数情况下页面再次正常加载;有时它会停止输出页面。它破坏了普通的html以及php块之前和之内。

The issue seems to almost be worse in the production environment; the only difference between the two would be the datasource connection to the DB.

生产环境中的问题似乎差不多;两者之间的唯一区别是与数据库的数据源连接。

Are there any known issues of this with PHP, ODBC, and MSSQL? It is obviously tied to the calls to the database, which are all stored procedures. Could it be an issue with the datasource?

PHP,ODBC和MSSQL是否存在任何已知问题?它显然与对数据库的调用有关,这些调用都是存储过程。这可能是数据源的问题吗?

Any input would be appreciated.

任何输入将不胜感激。

4 个解决方案

#1


1  

I consistently see this in "View Source" when it dies:

当它死亡时,我一直在“查看源代码”中看到这个:

<div class="wrap"> <a href="/research/vpr/">OVPR</a> <img alt=">" src=".

OVPR PHP页面使用ODBC,数据源和MSSQL中途停止加载”src =“。

I would guess that your image caching or image URL generating or image handling is probably broken somewhere, and it's aborting for lack of an image.

我猜你的图像缓存或图像URL生成或图像处理可能在某处被破坏,并且由于缺少图像而中止。

The > INSIDE the alt value is also not kosher. That needs to be escaped with http://php.net/htmlentities

> INSIDE的alt值也不是犹太洁食。这需要通过http://php.net/htmlentities进行转义

It might "work" but it won't validate, and a page that doesn't validate is just plain broken.

它可能“工作”但它不会验证,并且一个不验证的页面只是简单的破坏。

The DB connection differences between, say, localhost in DEV and separate boxes in PROD is probably changing the timing / frequency of the issue, but is almost for sure a red herring...

例如,DEV中的localhost和PROD中的单独框之间的数据库连接差异可能会改变问题的时间/频率,但几乎肯定是红鲱鱼...

Though if a DB call to look up the OVPR image is doing a die()...

虽然如果DB调用查找OVPR图像正在执行die()...

For sure, though, if you don't have 10 lines of error handling around every call to odbc_* or mssq_* in your database code, then you've done it wrong, and need to add that.

但是,当然,如果在数据库代码中每次调用odbc_ *或mssq_ *时都没有10行错误处理,那么你做错了,需要添加它。

PS It should be trivial to switch from ODBC to mssql_* or sybase_* driver, or PDO::* and eliminate at least one possible contender, if none of the above work out. I say again, though, that the DB is 99% for sure a red herring, and you've done something that will be obvious, dare I say silly, once you trace it through to the real cause...

PS如果以上都没有解决,从ODBC切换到mssql_ *或sybase_ *驱动程序或PDO :: *并消除至少一个可能的竞争者应该是微不足道的。不过,我再次说,数据库肯定是99%的红鲱鱼,而且你已经做了一些显而易见的事情,我敢说愚蠢,一旦你追溯到真正的原因......

#2


0  

Make sure there isn't a die or exit in the code anywhere

确保代码中没有骰子或退出

Edit -- If there is, remove this, and view the error

编辑 - 如果有,请删除它,然后查看错误

#3


0  

Have you checked normal debugging methods? What does the code look like - specifically, the error handling around your ODBC calls? You don't have a top level return or a misplaced die(), do you?

你检查过正常的调试方法吗?代码是什么样的 - 特别是围绕ODBC调用的错误处理?你没有*回报或错位(),对吗?

When I see the page in it's not-rendering state it seems to be because the page is clearly incomplete and it's XHTML.

当我看到页面处于非呈现状态时,似乎是因为页面显然不完整而且是XHTML。

I see it normally die here -

我看到它通常死在这里 -

<a href="/research/vpr/">OVPR</a>

#4


0  

Try bumping up your error reporting level so that you can see any warnings, errors, infos that might be suppressed at the server level.

尝试提高您的错误报告级别,以便您可以看到可能在服务器级别抑制的任何警告,错误和信息。

http://php.net/manual/en/function.error-reporting.php

// Report all PHP errors
<?php error_reporting(-1); ?>

#1


1  

I consistently see this in "View Source" when it dies:

当它死亡时,我一直在“查看源代码”中看到这个:

<div class="wrap"> <a href="/research/vpr/">OVPR</a> <img alt=">" src=".

OVPR PHP页面使用ODBC,数据源和MSSQL中途停止加载”src =“。

I would guess that your image caching or image URL generating or image handling is probably broken somewhere, and it's aborting for lack of an image.

我猜你的图像缓存或图像URL生成或图像处理可能在某处被破坏,并且由于缺少图像而中止。

The > INSIDE the alt value is also not kosher. That needs to be escaped with http://php.net/htmlentities

> INSIDE的alt值也不是犹太洁食。这需要通过http://php.net/htmlentities进行转义

It might "work" but it won't validate, and a page that doesn't validate is just plain broken.

它可能“工作”但它不会验证,并且一个不验证的页面只是简单的破坏。

The DB connection differences between, say, localhost in DEV and separate boxes in PROD is probably changing the timing / frequency of the issue, but is almost for sure a red herring...

例如,DEV中的localhost和PROD中的单独框之间的数据库连接差异可能会改变问题的时间/频率,但几乎肯定是红鲱鱼...

Though if a DB call to look up the OVPR image is doing a die()...

虽然如果DB调用查找OVPR图像正在执行die()...

For sure, though, if you don't have 10 lines of error handling around every call to odbc_* or mssq_* in your database code, then you've done it wrong, and need to add that.

但是,当然,如果在数据库代码中每次调用odbc_ *或mssq_ *时都没有10行错误处理,那么你做错了,需要添加它。

PS It should be trivial to switch from ODBC to mssql_* or sybase_* driver, or PDO::* and eliminate at least one possible contender, if none of the above work out. I say again, though, that the DB is 99% for sure a red herring, and you've done something that will be obvious, dare I say silly, once you trace it through to the real cause...

PS如果以上都没有解决,从ODBC切换到mssql_ *或sybase_ *驱动程序或PDO :: *并消除至少一个可能的竞争者应该是微不足道的。不过,我再次说,数据库肯定是99%的红鲱鱼,而且你已经做了一些显而易见的事情,我敢说愚蠢,一旦你追溯到真正的原因......

#2


0  

Make sure there isn't a die or exit in the code anywhere

确保代码中没有骰子或退出

Edit -- If there is, remove this, and view the error

编辑 - 如果有,请删除它,然后查看错误

#3


0  

Have you checked normal debugging methods? What does the code look like - specifically, the error handling around your ODBC calls? You don't have a top level return or a misplaced die(), do you?

你检查过正常的调试方法吗?代码是什么样的 - 特别是围绕ODBC调用的错误处理?你没有*回报或错位(),对吗?

When I see the page in it's not-rendering state it seems to be because the page is clearly incomplete and it's XHTML.

当我看到页面处于非呈现状态时,似乎是因为页面显然不完整而且是XHTML。

I see it normally die here -

我看到它通常死在这里 -

<a href="/research/vpr/">OVPR</a>

#4


0  

Try bumping up your error reporting level so that you can see any warnings, errors, infos that might be suppressed at the server level.

尝试提高您的错误报告级别,以便您可以看到可能在服务器级别抑制的任何警告,错误和信息。

http://php.net/manual/en/function.error-reporting.php

// Report all PHP errors
<?php error_reporting(-1); ?>