mysqli_stmt_bind_result上的PHP奇怪的段错误 [英] PHP weird Seg-faults on mysqli_stmt_bind_result

查看:134
本文介绍了mysqli_stmt_bind_result上的PHP奇怪的段错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当将PHP脚本从PHP 5.2迁移到PHP 5.3时,我偶然发现了以下问题: 该脚本的一般用途是数据挖掘. 我有一个将数据添加到MySQL服务器的过程. 由于它确实是重复性的,因此(前一阵子)我重写了它以使用MySQLi,尤其是准备好的语句,因为总共要执行3个查询. 无论如何,现在,在PHP 5.3服务器上,脚本在以下行崩溃:

When migrating a PHP script from PHP 5.2 to PHP 5.3, I've stumbled to the following problem: The general purpose of the script is data mining. I have a procedure inside that adds data to the MySQL server. Since it is really repetitive, I've rewritten it (a while ago) to use MySQLi, in particular prepared statements, since there are a total of 3 possible queries to perform. Anyway, now, on the PHP 5.3 server, the script is crashing on the following line:

mysqli_stmt_bind_result($prepCheck, $id1);

其中使用$prepCheck = mysqli_prepare($con, $checkQuery) or die("Error");创建$prepCheck的位置.该查询可以在MySQL服务器(即$ checkQuery)上正常运行,并且PHP代码也可以在以前的服务器上运行.

Where $prepCheck is created with $prepCheck = mysqli_prepare($con, $checkQuery) or die("Error");. The query runs fine on the MySQL server ($checkQuery, that is) and the PHP code was working, too, on the previous server.

使用strace运行脚本没有显示任何内容,因为其中的最后一件事是echo "Execute";的系统调用,即29936 19:44:18 write(1, "Execute\n", 8) = 8.

Running the script with strace didn't reveal anything, since the last thing in it is the system call for echo "Execute";, which is 29936 19:44:18 write(1, "Execute\n", 8) = 8.

连接对象不是FALSE,即使它是连接对象,它也应该因另一个错误而失败,对吗?

The connection object is not FALSE, and even if it was, it should fail with another error, right?

最奇怪的部分出现在这里: 当我运行脚本时,此过程不会失败,从而限制了访问的页面数,并且脚本成功完成.但是,当我设置一个更高的限制时,它会失败,总是在第一次调用此过程时,并且恰好在此行上.

Here comes the weirdest part: This procedure does not fail when I run the script, limiting the number of pages visited and the script completes successfully. However, when I set a higher limit, it fails, always on the first call to this procedure, and precisely on this line.

如果有人有什么建议可能导致这种情况,将不胜感激.

If anyone has any suggestions what could be causing this, they would be deeply appreciated.

如果有人需要看大图,我可以粘贴代码,但是过程很长而且很枯燥(可能就​​是脚本失败的原因:).

I can paste code if anyone needs to see a larger picture, but the procedure is very long and boring to death (may be that's why the script is failing :).

以下是脚本的启动方式:error_reporting(E_ALL); ini_set('display_errors', '1');. 除了'magical'Segmentation fault以外,没有错误报告.我没有使用APC.

Here is how the script starts: error_reporting(E_ALL); ini_set('display_errors', '1');. No error is reported besides the 'magical' Segmentation fault. I'm not using APC.

不确定是否相关,但是我正在使用CLI运行脚本,而不是Web界面.

Not sure if it's relevant, but I'm using CLI to run the script, not a web-interface.

PHP版本是5.3.8,MySQL版本是5.1.56.内存限制设置为64MB.

PHP version is 5.3.8, MySQL version is 5.1.56. The memory limit is set to 64MB.

失败的过程+一些其他代码在这里上传:http://codepad .org/KkZTxttQ .整个文件庞大又丑陋,我认为这无关紧要,因此我暂时不发布它.失败的行是113.

The procedure failing + some of the other code is uploaded here: http://codepad.org/KkZTxttQ. The whole file is huge and ugly, and I believe irrelevant, so I'm not posting it for now. The line that's failing is 113.

推荐答案

我自己的问题的答案,因为我已经解决了该问题,并且没有其他答案...

An answer to my own question, since I've solved the issue, and there are no other answers...

贷方@ jap1968指向我指向函数mysqli_stmt_error(我以为我不需要,因为我有error_reporting(E_ALL)).

Credit goes to @jap1968 for pointing to me to the function mysqli_stmt_error (which I assumed I would not need, since I have error_reporting(E_ALL)).

问题是MySQL具有非常奇怪的默认配置:特别是

The problem was that MySQL had a very weird default configuration: particularly

connect_timeout = 10
wait_timeout = 30

这导致MySQL服务器仅在30秒后关闭连接(根据MySQL网站,默认时间超过半小时).反过来,这导致mysqli_stmt_bind_result函数由于分段错误而失败.

This caused the MySQL server to close the connection after only 30 seconds (default is more than a half hour, according to MySQL website). This in turn, caused the mysqli_stmt_bind_result function to fail with a Segmentation Fault.

这篇关于mysqli_stmt_bind_result上的PHP奇怪的段错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆