PDO 绑定参数在临时和托管服务器上无提示地失败
我正在使用 WindowsXP 机器来开发 PHP 页面。我正在使用 PDO 连接到 MySQL 后端。在我的开发环境中它工作得很好,但它在我的 CentOS 5.5 测试服务器中默默地停止处理。经过一些调试,我发现它完全停在 '$stmt->bindParams' 部分。
我的声明如下:
$stmt = $dbh->prepare('SELECT * FROM MEMBERS WHERE ID=:what');
echo 'statement prepared'; //debug
$stmt->bindParam('what', $enteredid);
echo 'parameters bound'; //debug
也在我的开发机器中尝试了
$stmt->bindParam('what', $enteredid, PDO::PARAM_STR, 255);
这两种方法,但它在我的测试服务器中停止了。
我只能看到“声明已准备好”,但没有任何反应。
还尝试了托管环境中的页面。同样的事情也会发生。
I am using WindowsXP machine for the PHP pages I am developing. I am using PDO to connect to MySQL backend. In my development environment it works just fine but it silently stops processing in my CentOS 5.5 testing server. After some debugging, I found that it stops exactly at '$stmt->bindParams' section.
My statement is as follows:
$stmt = $dbh->prepare('SELECT * FROM MEMBERS WHERE ID=:what');
echo 'statement prepared'; //debug
$stmt->bindParam('what', $enteredid);
echo 'parameters bound'; //debug
also tried
$stmt->bindParam('what', $enteredid, PDO::PARAM_STR, 255);
both works in my development machine but it stops in my test server.
I can only see 'statement prepared' and nothing happens.
Also tried the page in hosting environment. Same thing happens.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
当你调用bindParam()时,你不需要传递':what'作为要绑定的占位符而不是'what'吗?不知道为什么这适用于 Windows 而不是 Linux...
When you call bindParam() don't you need to pass ':what' as the placeholder to bind to instead of 'what'? Not sure why this would work on Windows and not Linux though...
旧的,但有人可能会发现这很有用
正确的代码是:
Old, but someone might find this useful
The correct code is: