开发者

The user receives a truncated message (max 19109 chars) from a PHP script when calling to mysqli_real_connect

I have a problem with 1 of our PHP scripts, it sometime returns truncated message.

The flow:

  1. User call to search.php
  2. The script process the request:

    • a Connect to the DB
    • b Build XML using the SimpleXML class
    • c typeCast the SimpleXML to a string.
    • d print that string to the client.
  3. The user receive (output to the browser) only part of the message in some cases

after examining this issue, those are the facts I've found:

  1. The maximum length is 19109 chars -> more then that, it getting truncated.
  2. I logged the 2.c typeCast XML string and found out that the log contains the full XML (not truncated!).
  3. other scripts that return shorter/longer response are working fine.
  4. The problem is related somehow to the DB connection:

    • In order to check if the problem is related开发者_开发问答 to SimpleXML or something with the XML-String, I've printed (output to the browser) a diffrent-hardcoded-XML on #2.d -> it got truncated as well.

    • Then I tried finding what can cause it (while the diffrent-hardcoded-XML is still there), so I debugged the script using "die;". Then Iv'e found out that only if mysqli_real_connect or mysql_real_connect are called, the return value it truncated.

Any idea on how to solve/debug this issue?


Maybe message #2 give you an answer? In short, PHP manual refuses that such a function barely exists in PHP.

If this is the case, you might see that truncated output because you have implicit flush enabled, so the response is flushed to the browser immidiately during script execution. Than, at some moment script calls mysql_real_connect, which does not exists. This cause script to stop execution, so you see partially formed output. If you have display_errors disabled - you will not see the error message.

So, try enabling error output in your PHP installation (diplay_errors config directive). Another good way to resolve this is checking, if mysql_real_connect really exists with function_exists

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜