开发者

PHP page stops loading halfway, using ODBC, datasource, MSSQL

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

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

If you refresh the page repeatedly you will hopefully be able to see the issue.开发者_JAVA技巧 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.

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?

Any input would be appreciated.


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

<div class="wrap"> <a href="/research/vpr/">OVPR</a> <img alt=">" 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.

The > INSIDE the alt value is also not kosher. That needs to be escaped with 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...

Though if a DB call to look up the OVPR image is doing a 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.

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...


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

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


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?

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.

I see it normally die here -

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


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); ?>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜