我使用PHP-FPM和MySQL运行nginx服务器。 PHP安装了MySQL和MySQLi扩展,如phpinfo()
所确认。我上传了在localhost上完美工作的脚本,当我尝试加载页面时遇到了500错误。我的nginx日志显示:无法取得mysqli
2012/01/19 22:01:27 [error] 3393#0: *14 FastCGI sent in stderr: "PHP Warning: mysqli::prepare(): Couldn't fetch mysqli in /var/www/mydomain.com/chat/index.php on line 12
PHP Fatal error: Call to a member function execute() on a non-object in /var/www/mydomain.com/chat/index.php on line 13" while reading response header from upstream, client: 82.32.181.151, server: mydomain.com, request: "GET /chat/ HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "mydomain.com"
我用mydomain.com
取代了我的实际域。在index.php 12行我有这个:
$stmt = $mysqli->prepare('SELECT r_id, name, room_pass, max_users FROM `rooms` ORDER BY name ASC');
Google'ing后,我发现了一些原因。一个是我过早地关闭了我的数据库连接,不是这样。另一个是我混合了OOP和MySQLi函数的调用,这也不是问题。另外,我的数据库连接信息是正确的。
所以,我很难过。